Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

This message can not be used to set the state of incident to Closed. In order to set state of incident to Closed, use the CloseIncidentRequest message instead.

(0) ShareShare
ReportReport
Posted on by 417

This did not work

SetStateRequest setState = new SetStateRequest();
setState.State = new OptionSetValue(1);
setState.Status = new OptionSetValue(5);

setState.EntityMoniker = incident.ToEntityReference();

var result = (SetStateResponse)service.Execute(setState);


So I tried to do that

https://docs.microsoft.com/en-us/dotnet/api/microsoft.crm.sdk.messages.closeincidentrequest?view=dynamics-general-ce-9

BUT this

IncidentResolution resolution = new IncidentResolution
{
    Subject = "Case Closed",
};

Causes that

Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'IncidentResolution' could not be found (are you missing a using directive or an assembly reference?)

The usings are

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Ikarus.CRM.Plugins;
using Ikarus.CRM.Plugins.BusinessLogic;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Tooling.Connector;

This are the references

references.png

Why does the compiler not recognize the subclass?

EDIT: Link corrected

*This post is locked for comments

  • bernhards Profile Picture
    bernhards 417 on at
    RE: This message can not be used to set the state of incident to Closed. In order to set state of incident to Closed, use the CloseIncidentRequest message instead.

    That was doing the trick, thanks a lot. But how can I close the incident, without overwriting the already existing resolution or to create a duplicate?

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: This message can not be used to set the state of incident to Closed. In order to set state of incident to Closed, use the CloseIncidentRequest message instead.

    The example you're using is written for early-bound entity classes. This depends on having generated these classes using the CrmSvcUtil tool. When you generate the classes you choose the .Net namespace.

    Alternatively you can use latebound classes, in which case the code would be:

    var resolution = new Entity("incidentresolution");
    resolution["subject"] = "Case Closed";


    Note that with the late-bound approach you always use the logical (lower-case) names for entities and attributes

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans