Programmatically Working with Enumerations

  • Comments 4
  • Likes

OK, so – you've figured out how to create enumerations (in bulk even), use them in custom forms using the special ListPicker control, how to set enum property values, and how to add them to a form using form customization.  In this blog post, I'll show you how to manipulate enumerations programmatically using the SDK. Using this information you can create custom web forms, command line apps, PowerShell cmdlets, or Windows Workflow Foundation activities that need to manipulate enum data type properties.

Here are a few examples:

EnterpriseManagementGroup emg = new EnterpriseManagementGroup("localhost");


//Get all enumerations and list them in a list

foreach(ManagementPackEnumeration mpenum in emg.EntityTypes.GetEnumerations())





//Get a specific enumeration by GUID

ManagementPackEnumeration mpenumIncidentUrgencyHigh = emg.EntityTypes.GetEnumeration(new Guid("2F8F0747-B6CB-7996-FD4A-84D09743F218"));



//Get a specific enumeration by Name and MP

ManagementPack mpSystem = emg.ManagementPacks.GetManagementPack(SystemManagementPack.System);

Version verSystemVersion = mpSystem.Version;

string strSystemKeyToken = mpSystem.KeyToken;

ManagementPack mpWorkItemLibrary = emg.GetManagementPack("System.WorkItem.Library", strSystemKeyToken, verSystemVersion);

mpenumIncidentUrgencyHigh = emg.EntityTypes.GetEnumeration("System.WorkItem.TroubleTicket.UrgencyEnum.High",mpWorkItemLibrary);



//Get a parent enumeration and enumerate all of its children

ManagementPackEnumerationCriteria mpenumcriteriaChildrenOfIncidentUrgencyParent = new ManagementPackEnumerationCriteria("Parent = '04B28BFB-8898-9AF3-009B-979E58837852'");

IList<ManagementPackEnumeration> listenumIncidentUrgency = emg.EntityTypes.GetEnumerations(mpenumcriteriaChildrenOfIncidentUrgencyParent);

foreach (ManagementPackEnumeration mpenumIncidentUrgency in listenumIncidentUrgency)




Console application with examples can be downloaded from here.

Programmatically Working with Enumerations

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Very interesting. But if an object has a ObjectStatus set already (with an enumeration value), how do you alter that value?

  • @Joakin

    You can see examples of setting enum value properties in the Create Incident sample:

  • Thanks Travis! That does look like what I need. As soon as our development environment is up again i will try it out!

  • For children - I would use GetChildEnumerations /Maybe new feature since this was written/.