- 24 Jan 2024
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
Updating an Array with New Records: Recommended Logic Blocks
- Updated on 24 Jan 2024
- 1 Minute to read
- Contributors
- Print
- DarkLight
- PDF
I need to update an array with new records through a behavior. What are the recommended logic blocks to be used for this requirement?
There are two blocks that can be used to update an array with new records. However, one block is more strongly recommended, and the reasons for preferring it over the other are explained below.
Variable component > Set block
In the above image, Enrollist is an array where a new record is required to be added.
How it Works:
The Set block inserts the record directly into the Enrollist array. This method is time-efficient and hence recommended to be used for all scenarios where array needs to be updated.
List component > in list block
In the above image, Enrollist is an array where a new record is required to be added.
How it works:
- The block takes a copy of the existing array.
- It adds the new object into the copy.
- Finally, it assigns the modified copy back to the original array.
The drawback of this method is that it increases the process time, especially when dealing with large datasets.