Skip to content

MS Dynamics C# retrieving label/name

This is an example of retrieving the label / name of a code instead of writing another function to look it up.

fakecode --> value (int)
fakecode (formatted) --> FormattedValues["fakecode"]

So in C# you can do:

string labelName =  entity.FormattedValues.Contains("fakecode")
? entity.FormattedValues["fakecode"]
: null;

Or

string labelName = entity.FormattedValues.Contains("fakecode")
? entity.FormattedValues["fakecode"].ToEmptyStringIfNull()
: string.Empty;

Published inC#CodingMicrosoft

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *