Skip to main content

Notifications

Announcements

No record found.

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,530

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

  • rthompson Profile Picture
    rthompson 1,530 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."}

  • Suggested answer
    ARIFNIIT Profile Picture
    ARIFNIIT 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.

  • Verified answer
    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);

  • Verified answer
    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
    RaviKashyap Profile Picture
    RaviKashyap 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
    gdas Profile Picture
    gdas 50,089 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
    Aric Levin Profile Picture
    Aric Levin 30,188 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.

  • a33ik Profile Picture
    a33ik 84,325 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?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans