The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I recently had a tricky problem created by myself when I deleted a Status reason without fully engaging my brain. Read more about it in the link below
CRM 2013 – Understanding Status and Status Reason – think before deleting them
If you try to add a status reason in CRM you will quickly find you can specify the label but not the value
I’m not sure why it works like this but it was very frustrating when I was trying to add a Status Reason and wanted to specify the value.
Someone did murmer the words
“Direct Database update”
My advice to CRM developers is to not even think about unsupported changes because Microsoft will un-support your CRM if they find out
Why you shouldn’t put unsupported customizations in Microsoft Dynamics CRM
Don’t do unsupported CRM customizations, 99.9 percent of the time there is another way and for the 0.1 percent of the time you should go back and tell the customer you can’t do it because it’s unsupported– Hosk Quotes
When using the CRM SDK it usually a journey of discovery, reading one page, which leads you to another page, slowly pick up the clues, information and examples until you have enough information to tackle the problem.
I say it so often it’s made it to my Hosk Wisdom quotes page
Always start with the CRM SDK, you will find the answer to your current problem and solutions to your future CRM problems – Hosk
I knew status reasons fields are option sets and option sets store information
Value (int number)
The description is held as Metadata. If you want to learn more about metadata read my blog post Understanding CRM Metadata.
Using the Metadata services it’s possible to add, update and retrieve Metadata fields.
The Work with attribute metadata page had a section called Insert a new status value. This was good but in the example it didn’t specify the value. I needed to specify the value because I was trying to add back a previously deleted status reason, read this blog post to find out why I was trying to do that.
When using the CRM SDK you often need to earn the answer, this means you need to read, analyse and understand how parts of the CRM SDK work. This is the sample code
It’s adding a Statecode (e.g. Active/In Active) but I want the StatusCode.
I look at the msdn page for InsertStatusValueRequest Class, this links to the same code as above but on the left you can see more pages you can look at.
It’s often worth looking at the related documentation for classes in CRM. In this case I look at the InsertStatusValueRequestProperties
There it is Value, yippeee, that’s what I want to set. I can see from the documentation it’s optional, which would explain why it wasn’t included in the sample code. Most people are not worried what the value of a new status reason is.
I have the theory, now it’s time to put it into practice.
Here is the code I used to create a status reason and specify the value of the status reason to be 100000001. Quite how the number got created like that puzzled me, unless a previous developer used the same code!
// Use InsertStatusValueRequest message to insert a new status
// in an existing status attribute.
// Create the request.
InsertStatusValueRequest insertStatusValueRequest =
AttributeLogicalName = "statuscode",
EntityLogicalName = Incident.EntityLogicalName,
Label = new Label("Correspondence Withdrawn", 1033),
StateCode = 1,
Value = 100000001
// Execute the request and store newly inserted value
// for cleanup, used later part of this sample.
int _insertedStatusValue = ((InsertStatusValueResponse)this.crmService.Execute(
One last point of interest was I hard-coded the UK locale, Microsoft example just specified a variable but didn’t show where it was assigned. I looked up the value on this page – Locale ID’s assigned by Microsoft.
As this was a one-off, I was worried about the hard coding
Business Applications communities