KVSKBAMasterDocFieldData#
Procedures#
Init() :#
Summary: Initializes the field data dictionary by clearing all existing entries.
procedure Init():
Remarks: Call this procedure before building a new set of field data to ensure a clean state. This clears both the internal dictionary and the cached field data text.
GetFieldDataText() : Text#
Summary: Retrieves all dictionary values as a formatted text string.
procedure GetFieldDataText(): Text
Returns: A formatted text string containing all key-value pairs from the dictionary.
Remarks: The returned text uses the format: key1=value1[separator]key2=value2[separator]... The separator character is ASCII 177 (±). Returns an empty string if the dictionary is empty.
GetFieldDataTextInclCustomFields(Codeunit KVSKBAMasterDocFieldData) : Text#
procedure GetFieldDataTextInclCustomFields(var CustomFields: Codeunit "KVSKBAMasterDocFieldData"): Text
GetFieldDataCount() : Integer#
Summary: Retrieves the number of entries in the field data dictionary.
procedure GetFieldDataCount(): Integer
Returns: The count of key-value pairs in the dictionary.
Remarks: Use this to check if any field data has been added before processing.
GetValue(Text) : Text#
Summary: Retrieves a dictionary value by its key.
procedure GetValue(DictKey: Text): Text
Parameters:
DictKey: The key to look up in the dictionary.
Returns: The value associated with the key, or an empty string if the key doesn't exist.
Remarks: This is a safe method that returns an empty string rather than throwing an error if the key is not found.
InsertToFieldDataDict(Dictionary) : Integer#
procedure InsertToFieldDataDict(var Dict: Dictionary): Integer
AddToFieldDataDict(Codeunit KVSKBAMasterDocFieldData) : Integer#
procedure AddToFieldDataDict(var DestFieldDataDict: Codeunit "KVSKBAMasterDocFieldData"): Integer
GetFieldDataDict(Dictionary) : Integer#
procedure GetFieldDataDict(var Dict: Dictionary): Integer
AddValueText(Text, Text) :#
Summary: Adds or updates a text value in the field data dictionary.
procedure AddValueText(KeyText: Text; Value: Text):
Parameters:
KeyText: The key under which to store the value.Value: The text value to store.
Remarks: If the key already exists and the value is different, the old value is replaced. If the key exists with the same value, no action is taken (optimization). This is the base method for all typed AddValue methods.
AddValueDecimal(Text, Decimal, Text) :#
Summary: Adds a formatted decimal value to the field data dictionary.
procedure AddValueDecimal(KeyText: Text; DecimalValue: Decimal; FormatString: Text):
Parameters:
KeyText: The key under which to store the value.DecimalValue: The decimal value to store.FormatString: Optional format string. If empty, a standard format is used.
Remarks: The standard format is '<precision, 2:5><Standard Format,0>' which provides 2-5 decimal places. Use FormatString to specify custom decimal formatting (e.g., '0.00' for exactly 2 decimal places). The OnBeforeStandardAddValueTextInAddValueDecimal event allows customization of the standard format.
AddValueAmount(Text, Decimal, Code[10], Text) :#
Summary: Adds a formatted amount value with currency consideration to the field data dictionary.
procedure AddValueAmount(KeyText: Text; DecimalValue: Decimal; CurrencyCode: Code[10]; FormatString: Text):
Parameters:
KeyText: The key under which to store the value.DecimalValue: The amount value to store.CurrencyCode: The currency code for formatting (empty for LCY).FormatString: Optional format string. If empty, currency-specific format is used.
Remarks: Uses the AutoFormat codeunit to apply currency-specific formatting rules. The currency code determines decimal places and formatting symbols. For local currency (LCY), use an empty currency code.
AddValueUnitAmount(Text, Decimal, Code[10], Text) :#
Summary: Adds a formatted unit amount value with currency consideration to the field data dictionary.
procedure AddValueUnitAmount(KeyText: Text; DecimalValue: Decimal; CurrencyCode: Code[10]; FormatString: Text):
Parameters:
KeyText: The key under which to store the value.DecimalValue: The unit amount value to store.CurrencyCode: The currency code for formatting (empty for LCY).FormatString: Optional format string. If empty, currency-specific unit format is used.
Remarks: Similar to AddValueAmount but uses unit amount formatting which may have different decimal precision. Typically used for unit prices, unit costs, and other per-unit monetary values.
AddValueInteger(Text, Integer) :#
Summary: Adds a formatted integer value to the field data dictionary.
procedure AddValueInteger(KeyText: Text; IntValue: Integer):
Parameters:
KeyText: The key under which to store the value.IntValue: The integer value to store.
Remarks: The integer is converted to text using the default format. No thousand separators or special formatting is applied.
AddValueBoolean(Text, Boolean) :#
Summary: Adds a formatted boolean value to the field data dictionary.
procedure AddValueBoolean(KeyText: Text; BooleanValue: Boolean):
Parameters:
KeyText: The key under which to store the value.BooleanValue: The boolean value to store.
Remarks: The boolean is converted to text as 'true' or 'false'. The text is language-neutral (not translated).
AddValueDate(Text, Date) :#
Summary: Adds a formatted date value to the field data dictionary.
procedure AddValueDate(KeyText: Text; DateValue: Date):
Parameters:
KeyText: The key under which to store the value.DateValue: The date value to store.
Remarks: Uses format option 1 which respects user language settings. This ensures dates are displayed according to the user's regional preferences.
AddValueTime(Text, Time) :#
Summary: Adds a formatted time value to the field data dictionary.
procedure AddValueTime(KeyText: Text; TimeValue: Time):
Parameters:
KeyText: The key under which to store the value.TimeValue: The time value to store.
Remarks: Uses 24-hour format HH:MM (e.g., '14:30'). Seconds are not included in the output.
UpdateFieldTextValue(Text, Text, Text) :#
Summary: Updates a single field value within a formatted LineFields text string.
procedure UpdateFieldTextValue(var LineFields: Text; KeyText: Text; ValueText: Text):
Parameters:
LineFields: The formatted text string containing multiple field values (modified by reference).KeyText: The key of the field to update.ValueText: The new value for the field.
Remarks: This is useful for modifying individual field values without reconstructing the entire LineFields text. If the old and new values are identical, no modification is made. The field must already exist in the LineFields text; this method doesn't add new fields.
GetFieldTxtValue(Text, Text) : Text#
Summary: Retrieves a single field value from a formatted LineFields text string.
procedure GetFieldTxtValue(LineFields: Text; KeyText: Text): Text
Parameters:
LineFields: The formatted text string containing multiple field values.KeyText: The key of the field to retrieve.
Returns: The value associated with the key, or an empty string if not found.
Remarks: This parses the LineFields text to extract a specific value without loading the entire dictionary. Useful for reading individual values from stored or transmitted field data. Returns empty string if the key is not found in the text.
GetDictFieldFormat() : Text#
Summary: Retrieves the format string used for field data entries.
procedure GetDictFieldFormat(): Text
Returns: The format string pattern for field entries (e.g., '%1=%2%3').
Remarks: This is primarily used internally but exposed for parsing or debugging purposes. The pattern is: key=value[separator].
GetSeparatorChar() : Char#
Summary: Retrieves the separator character used between field entries.
procedure GetSeparatorChar(): Char
Returns: The separator character (ASCII 177, ±).
Remarks: This character separates individual key-value pairs in the formatted field data text. ASCII 177 was chosen because it's unlikely to appear in normal business data. Use this when manually parsing or constructing field data strings.
Events#
OnBeforeStandardAddValueTextInAddValueDecimal(Text, Decimal, Text) :#
Summary: Integration event triggered before applying standard format in AddValueDecimal.
[IntegrationEvent(false, false)]
local procedure OnBeforeStandardAddValueTextInAddValueDecimal(KeyText: Text; DecimalValue: Decimal; var StandardFormatString: Text):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBAMasterDocFieldData", 'OnBeforeStandardAddValueTextInAddValueDecimal', '', false, false)]
local procedure DoSomethingOnBeforeStandardAddValueTextInAddValueDecimal(KeyText: Text; DecimalValue: Decimal; var StandardFormatString: Text)
begin
end;
Parameters:
KeyText: The key for which the decimal value is being formatted.DecimalValue: The decimal value being formatted.StandardFormatString: The standard format string (can be modified).
Remarks: Use this event to customize decimal formatting based on specific keys or values. For example, you could apply different precision rules for quantity vs. amount fields. Modify StandardFormatString to change the format that will be applied.