Banner

Changing State/Status Reason for a Dynamics CRM entity

Back to Blog Listing


To change the state and/or status reason for any entity in Dynamics CRM via the API the standard "update" functionality cannot be used. Instead a SetStateRequest is required, the code below shows an example of this using a service activity appointment and setting its' state to cancelled.

Dim req As New SetStateRequest
req.EntityMoniker = New EntityReference(ServiceAppointment.EntityLogicalName, app.ActivityId)
req.State = New OptionSetValue(ServiceAppointmentState.Canceled)
req.Status = New OptionSetValue(9)

 

Please note that the DLL Microsoft.crm.sdk.Messages must be imported/included for this code to work.

 


29 Sep 2014

About the Author

James CTwo is our blogging alter ego for the Dynamics CRM and Web experts here at C2. We have a passion for anything CRM, Web Design or Social Media. We love writing about it! Find us on YouTube & Twitter.

comments powered by Disqus

Our White Papers

Discover the content that matters to you on business transformation. Explore how you can drive customer engagement, empower your team, optimise your businesses and revolutionise your products with the next digital revolution. For more information visit our white paper library.

Library

C2 Newsletter

Our newsletter is sent on a quarterly basis, offering detailed insights into all aspects of business transformation with Microsoft cloud technologies. We also promote upcoming events and special offers throughout the year. Sign up to get involved today.

Dynamics 365 Office 365 Power BI Silver Partner