Share all details about your problem, including any error messages you may have received.
I am adding a “Save and Add Another” button to my form with the action Refresh.
I need to inject a script to accumulate the data gathered from the user into a map and pass it to the workflow.
Is there an option to run this script on load from the form side? Or should I add it on the workflow side?
If it should be on the workflow side, does this mean the Refresh button re-initiates the step in the workflow again?
If yes, how can I inject this script when the attribute for this step is set as Approval? and all other nested script attributes are called on submission not on refresh?
Yep—I’ve run into this. Short version: use the workflow side to accumulate, and don’t rely on a “Refresh” to run business logic.
What “Refresh” really does in IIQ forms
Refresh is a server post-back that re-renders the same step/work item.
It does not advance the workflow and doesn’t run “on submit” scripts tied to the step.
On refresh, the form’s form/field rules re-evaluate (visibility, required, defaults, value-change, validations), but submit/transition logic does not fire.
Where to put the accumulation logic
Best practice: do it on the workflow side and use a submit + loop-back pattern instead of trying to execute logic on Refresh.
Pattern that works reliably:
Keep an accumulator variable (List/Map) in the workflow.
The form collects a single item (one “row”).
The “Save & Add Another” button should Submit the form, run a workflow script/activity that appends the current inputs to the accumulator, clears the form fields, and loops back to the same form step to capture the next item.
When the user is done, they click the standard Submit/Continue to move forward.
If you insist on using a Refresh button
You can only run logic that is supported by form-level rules (e.g., Initialization/Pre-Display, Value-Change, Validation).
A common workaround is a hidden “accumulator” field updated by field on-change rules; on Refresh the field values persist and re-render. This is UI-friendly but fragile for real business logic and doesn’t replace workflow-side persistence.
“On load” script from the form side?
Use the form’s Initialization / Pre-Display rule to load existing accumulated data (from the workflow variable) into the form when it opens or refreshes.
That’s good for initializing state, not for committing new rows—commit should happen on submit.
What if the step attribute is Approval?
An Approval step’s “script attributes” run on submit, not on refresh.
If you need multi-item data entry, don’t overload the Approval step for that. Use a dedicated Form step (collect items with the loop-back pattern), then transition into the Approval step once collection is finished.
TL;DR
Refresh = re-render, no submit logic.
Do accumulation in the workflow with a submit + loop-back (“Save & Add Another”) pattern.
Use form Initialization to load state; use Approval only after data collection is done.
Hi @purovitzz
Many thanks for your detailed reply, much appreciated.
Based on this, I have decided to proceed with implementing it from the workflow side, but I kindly need some clarification.
As far as I know, the approval step is responsible for launching the form and gathering the data. So, I think I need to loop over the step with the approval tag and add another tag in the same step, such as afterscript, to store the data in a map. Then, once the user clicks Submit, the process should transition to the next step, which handles data validation and then launches the workflow for provisioning — which I believe is responsible for sending the bulk work item to the approver. Am I correct?
However, as far as I know, the afterscript only runs after approval. I am not exactly sure how the form is considered approved, and will it also be considered approved if the Save & Add Another button is pressed, since its action is set to Next?
Additionally, I would like to confirm if it is possible to implement a custom button so that I can differentiate whether the next action is initiated by the Submit button or by Save & Add Another.