web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Crm Plugin - Added new status reason and updating the statusCode not working

(0) ShareShare
ReportReport
Posted on by 1,532

I have a custom entity.  I added a new status reason called "Disable".  The status code is "100,000,000".

When updating the statecode and statuscode I get an error message "OrganizationServiceFault". 

int stateCode = 0;
int statusCode = 100000000;
questionEntity["statecode"] = new OptionSetValue(stateCode); //Status
questionEntity["statuscode"] = new OptionSetValue(statusCode); //Status reason
service.Update(questionEntity);

Any ideal on why this is not working?

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Hello,

    Can you please post exact exception that you get?

    Can you please confirm that this status reason is for "Active" state code?

  • Verified answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Are you passing Id to the question Entity?

    Entity questionEntity = new Entity("new_question");

    questionEntity.Id = questionId;

    questionEntity["statecode"] = new OptionSetValue(stateCode); //Status

    questionEntity["statuscode"] = new OptionSetValue(statusCode); //Status reason

    service.Update(questionEntity);

    Is statusCode 100000000 an Active Status or Inactive Status.

    If Inactive the statecode should be 1 not 0.

    If this is not what you are looking for, then please provide the actual error message that you are receiving.

    Hope this helps.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Hi,

    Your code is correct , only thing you need to check as Aric mentioned whether you have created the status reason  with the value  100000000 statecode Active or Inactive.

    Try to pass 1 in state code seems you have created thw custom one in inactive state code. Here is the original value below mentioned. Hope this helps.

    _____________________

    State

    0 : Active

    Status Reason

    1 : Active

    =================

    State

    1 : Inactive

    Stutus Reason

    2 : Inactive

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Hi,

    It is most likely (as mentioned by above) that you have added the status reason under the "Inactive" status and in your code you are setting "Active" status i.e. '0'

    Hope this helps!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Hello,

    You can not update status like this

    Please follow this link.

    www.magnetismsolutions.com/.../Change_the_Status_of_Record_using_Plugin_in_Dynamics_CRM_2011.aspx

    Hope you can understand what I mean!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    Hi,

    You have to use setStateRequest to update the status.

    Example:

    SetStateRequest jobCardStatus = new SetStateRequest

                               {

                                   EntityMoniker = new EntityReference

                                   {

                                       Id =Guid ,//Pass guid of record

                                       LogicalName = "abc",

                                   },

                                   State = new OptionSetValue(1),

                                   Status = new OptionSetValue(2),

                               };

                               service.Execute(jobCardStatus);

  • Suggested answer
    ARIFNIIT Profile Picture
    1,391 on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    You can not update state , status and owner field using service.update(). Use respective Message. for example use SetStateRequest  to change state and status and AssignRequest to change Owner.

  • rthompson Profile Picture
    1,532 on at
    RE: Crm Plugin - Added new status reason and updating the statusCode not working

    My Error message is the following.

    "100000000 is not a valid status code for state code new_questionState.Inactive on new_question with Id c38fa26d-2b20-e811-80da-005056ba7ce0."}

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans