GetEnums
You can use the GetEnums function to retrieve all possible enumeration values and their corresponding display labels for a specified enumeration code. The function also supports language-specific labels when a language code is provided.
When to use
You can use this function to:
- Programmatically retrieve all valid values and labels for an enumeration code.
- Retrieve enumeration labels in a language other than the default English.
When not to use
You cannot use this function when a single enumeration value label is needed, as iterating through the complete dictionary may result in unnecessary processing overhead.
Syntax
Dictionary<string, string> GetEnums(string enumCode, string languageCode = "EN-US");
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| enumCode | string | Yes | The enumeration code used to retrieve values and labels. |
| language | string | Optional | The language code for the labels to be returned in. By default the language is set to EN-US.
Note: The function supports multilingual retrieval, for example, FR-FR, DE-DE).
|
Return Value
The application returns a Dictionary<string, string> containing the enumeration values and enumeration labels. An empty dictionary is returned if no matching enumeration values exist for the specified code.
Prerequisites
The enumeration code needs to be configured in the system. If the enumeration code is not configured, an empty dictionary is returned.
Examples
- Example 1
-
Retrieve enum values in the default language (EN-US).
using System; using Formation.Shared.Defs; using System.Data; using System.Collections.Generic; using System.Xml; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { Dictionary<string, string> enums = GetEnums("C_FORMULACLASS"); foreach (KeyValuePair<string, string> entry in enums) { // entry.Key → enum value // entry.Value → display label MessageList(entry.Key + " : " + entry.Value); } return 111; } }
- Description
- This example fetches all enumeration values and their EN-US labels for the C_FORMULACLASS enumeration list.
- Example 2
-
Retrieve enum values in French.
Retrieve enum values in French
- Description
- This example fetches all enumeration values and their French labels for the C_BRAND enumeration list.
- Example 3
-
Check if a specific enum value exists.
using System; using Formation.Shared.Defs; using System.Data; using System.Collections.Generic; using System.Xml; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { Dictionary<string, string> enums = GetEnums("C_ITEMCLASS"); if (enums.ContainsKey("MYVALUE")) { string label = enums["MYVALUE"]; MessageList("Label: " + label); } else { MessageList("Enum value not found."); } return 1L; } }
- Description
- This example retrieves enumeration labels for C_ITEMCLASS, checks for a specific value, and displays the corresponding label.