GetEnumsByDbField
You can use the GetEnumsByDbField function to retrieve enumeration values and their corresponding display labels based on a business object and database field name. The function resolves the enumeration configuration by checking the validation records ENUM_CODE or ENUM_QUERY based on the ENUM_IND value for the specified field. The function also supports language-specific label retrieval.
When to use
You can use this function to:
- Retrieve enumeration values and labels associated with a specific database field on a business object.
- Retrieve enumeration values when the enumeration code is unknown, but the business object symbol and field name are known.
Syntax
Dictionary<string, string> GetEnumsByDbField(string objsymbol, string dbFieldName, string languageCode = "EN-US", string subCode = " ");
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| objSymbol | string | Optional |
The symbol of the object.
Note: You can use empty quotation marks ("") for the current workflow symbol.
|
| dbFieldName | string | No | The database field name on the business object whose enum configuration is used to retrieve values and labels. |
| languageCode | string | No | The language code for the labels to be returned in. By default the language is set to EN-US if not provided or if an invalid code is passed.
Note: 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 if the operation is successful.
- An empty dictionary is returned if no matching enumeration values exist for the given code.
- The function returns a dictionary of enum values and their corresponding labels.
Prerequisites
The enumeration code must be configured in the system, otherwise an empty dictionary is returned.
Examples
- Example 1
-
Retrieve enum values in the default language (EN-US) by db field name(Corresponds to the field name in the UI).
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> enumsEN = GetEnumsByDbField("FORMULA", "CLASS"); foreach (KeyValuePair<string, string> entry in enumsEN) { // entry.Key → enum value // entry.Value → display label MessageList(entry.Key + " : " + entry.Value); } return 1L; } }
- Description
- This example fetches all enumeration values and their EN-US labels for the CLASS field. The values correspond to the C_FORMULACLASS enumeration list.
- Example 2
-
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> enumsEN = GetEnumsByDbField("FORMULA", "USAGE"); if (enumsEN.ContainsKey("MYVALUE")) { string label = enumsEN["MYVALUE"]; MessageList("Label: " + label); } else { MessageList("Enum value not found."); } return 1L; } }
- Description
- This example retrieves enumeration labels for the USAGE field, checks for a specific value MYVALUE, and displays the corresponding label.