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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

C# UpdateRequest - Updating the status of a record

(0) ShareShare
ReportReport
Posted on by

The following code should update the status of a ServiceAppointment record to closed. Although the code runs with no errors, the status of the record remains as open.

ServiceAppointment oServiceAppointmentZ = (ServiceAppointment)oOrgServiceZ.Retrieve(ServiceAppointment.EntityLogicalName, oServiceActivityGuidZ, new ColumnSet("activityid", "subject"));

oServiceAppointmentZ.StatusCode = new OptionSetValue((int)ServiceAppointmentState.Closed);

UpdateRequest oUpdateSAZ = new UpdateRequest()
{
    Target = oServiceAppointmentZ
};

oOrgServiceZ.Execute(oUpdateSAZ);

Examples I can find say to use a setting called Status (i.e. oServiceAppointmentZ.Status) but this does not exist and is probably related to older versions of Dynamics CRM. There is another field called StateCode but it is read-only.

Any suggestions?

[Edit: Ignore the 5. and 10. above - some bug(?) in the post code editor.]

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Abhishek Dhoriya Profile Picture
    1,013 on at

    Hi,

    There are two OOB fields inter related to each other for all entities.

    1) StateCode : INT type with values (0: Active, 1: Inactive)

    2) StatusCode: INT type

    You can retirve Stauts code with rerive service call. But if you want to update the status you have to use EntityMoniker Object in service call .

  • Community Member Profile Picture
    on at

    We are on the latest version (as far as I know) - 2015 Online (Spring).

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans