Visual Data Mapper - Iteration Function
First published on: 10/30/2024/6:41 pm
The Iteration Function mapping type for Saltbox is designed to automatically generate sequential numbers for array elements. This enhances the data handling capabilities of your systems. Key features of this mapping type include:
- Auto Number Generation: The Iteration Function automatically assigns a unique iteration number to each element in an array, streamlining the process of indexing for both simple and complex data structures.
- Support for Parent Nodes: It also offers the ability to use iteration numbers from parent nodes, enabling the creation of hierarchical iteration schemes. This is especially useful when dealing with nested arrays or when the data structure requires maintaining a relational context.
- Starting Value Offset: Set the starting value to 1, or offset it to some other value, depending on the needs of your system.
- Enhanced API Compatibility: With this mapping type, generating iteration numbers for arrays and nested arrays becomes simpler, making it particularly effective for APIs like the B1WebAPI. This reduces the need for manual numbering logic and improves data consistency across integrations.
The Iteration Function map type significantly improves the ease and efficiency of automatically generating iteration numbers, saving time and reducing errors in complex data processing scenarios.
Example
In the following example, LineNo need to be generated automatically in the array:
<Document>
<Header>
<CustomerCode>C100000</CustomerCode>
</Header>
<Lines>
<Line>
<LineNo>1</LineNo>
<ItemCode>Item1</ItemCode>
</Line>
<Line>
<LineNo>2</LineNo>
<ItemCode>Item2</ItemCode>
</Line>
</Lines>
</Document>
Users can set ‘Starting Value’ as well. Its default value is 1.
Output:
The Line No generates automatically incremented numbers.
Example of Nested Array Iteration
In scenarios involving nested arrays, where the user wishes to reference a parent node within child nodes, the following example demonstrates this functionality. The example includes a serial number node in which the serial number array requires the base line number (from the parent node), while also generating its own unique line number.
<Document>
<Header>
<CustomerCode>C100000</CustomerCode>
</Header>
<Lines>
<Line>
<ItemCode>Item1</ItemCode>
<LineNo>1</LineNo>
<SerialNumbers>
<BaseLineNo>1</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>1</LineNo>
</SerialNumbers>
<SerialNumbers>
<BaseLineNo>1</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>2</LineNo>
</SerialNumbers>
<SerialNumbers>
<BaseLineNo>1</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>3</LineNo>
</SerialNumbers>
</Line>
<Line>
<ItemCode>Item2</ItemCode>
<LineNo>2</LineNo>
<SerialNumbers>
<BaseLineNo>2</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>1</LineNo>
</SerialNumbers>
<SerialNumbers>
<BaseLineNo>2</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>2</LineNo>
</SerialNumbers>
<SerialNumbers>
<BaseLineNo>2</BaseLineNo>
<SerialNo>asd</SerialNo>
<LineNo>3</LineNo>
</SerialNumbers>
</Line>
</Lines>
</Document>
BaseLineNo = Line (Parent) node number
LineNo = SerialNumbers iteration number
Output
The above result demonstrates that the LineNo (Line), BaseLineNo (SerialNumbers), and the LineNo from the parent node (Line) are all generated by VDM (Visual Data Mapper).
Last modified: 05/20/2025/5:17 pm |
On this page