INSERT
Use the INSERT function to insert a new item into an Array at the specified position.
Use
INSERT( array, item, position )
Insert an item into an array at the position given.
| Parameter | Required | Description |
|---|---|---|
| array | Yes | any array of items |
| item | Yes | the item to insert |
| index | Yes | the position in the array to insert the item (starting at 1) |
| Returns | Array matching the type of array |
Examples
Dynamic Activity Assignment (Prioritizing an Approver)
In GoApprove, you can use INSERT within an Activity Assignment formula to modify a list of people before a task is assigned. This is useful when a submitter provides a list of approvers, but the system needs to inject a specific authority figure into a priority slot.
- Scenario: A submitter selects a list of colleagues to review a proposal in a Person Array called
@Trigger.out.ApproverList. The workflow requires that the "Compliance Manager" is always the first person in that list, regardless of who else was chosen. - Formula:
INSERT(@Trigger.out.ApproverList, 'person:Adele Vance', 1) - Logic:
@Trigger.out.ApproverList: The original array of people selected by the user.'person:Adele Vance': The literal person value being added.1: The target position. This places Adele at the very beginning of the array.
- Outcome: Adele Vance is inserted at position 1, and all other people in the original array are pushed down by one slot.
Updating a Project Queue via Variable Updates
You can use INSERT in a Variable Update formula to manage a dynamic list of tasks or milestones stored in a Variable. This allows you to "inject" new requirements into an existing plan at a specific stage.
- Scenario: You maintain a Text Array variable called
$ProjectMilestones. When a specific high-risk condition is met, you need to insert a "Legal Review" task into the second slot of that list. - Formula:
INSERT($ProjectMilestones, "Legal Review", 2) - Logic:
$ProjectMilestones: The current variable holding the collection of project steps."Legal Review": The text literal being inserted into the list.2: The position index.
- Outcome: The formula returns a new version of the array where "Legal Review" is the second item. This new array then replaces the old value of the
$ProjectMilestonesvariable.