Error: Variable evaluation lag in ForEach workflow post-conditions - Automic Automation.
search cancel

Error: Variable evaluation lag in ForEach workflow post-conditions - Automic Automation.

book

Article ID: 452982

calendar_today

Updated On:

Products

Automic Automation

Issue/Introduction

ForEach workflows experience a one-iteration lag when evaluating variables in the post-conditions of loop-body tasks. This occurs when variables are updated using the :PUBLISH script command.

Symptoms

  • Post-condition evaluation uses the variable value from the previous iteration instead of the current one.
  • In a loop with $N$ iterations, iteration $N$ evaluates data from iteration $N-1$.
  • The last iteration's variable updates are not processed if no subsequent iteration follows.

Environment

  • Automic Automation 26.X
  • Automic Automation 24.4.X

Cause

In the Automation Engine's runtime, ForEach loop-body positions (EJPP rows) are reused/recycled across every iteration. Only the task pointer (EJPP_TaskIdnr) is updated. Because post-condition checks (CHK_POSC) are processed as asynchronous messages, a timing race can occur: if the engine advances to the next iteration before the previous iteration's check finishes, the check resolves against the updated (next) task context, resulting in stale data.

Resolution

Use :PSET instead of :PUBLISH to update parent workflow variables within a ForEach loop.

  1. Identify script variables published to the workflow level within the loop-body task.
  2. Replace :PUBLISH &VARIABLE#, , WORKFLOW with :PSET &VARIABLE# = &VALUE#.
  3. Unlike :PUBLISH, the :PSET command updates the parent ForEach container's stable EH/EV record immediately, ensuring it is not affected by the per-iteration recycling of the loop-body position.

For defects and enhancements, subscribe to this article (Reference: KB 275360) to receive updates on the formal fix status.

Additional Information

Standard (non-loop) workflows are not affected by this behavior because they do not recycle position records.