Recording .completedBy with Use of Loops

Meghan_550057
Meghan_550057 Posts: 107
edited October 2019 in Show and Tell

When using a loop in your process (Pushbot: Reopen Task and Reset Dependent Tasks action) and trying to dynamically record the user that completed a particular action for audit purposes, using the globally available field tasks[“task-name”].completedBy won't continue to pull the refreshed user completing a task with each loop of the process. Each time a loop occurs, a particular task is appended with a - + # of loop ex: task-name-1 (1st loop), task-name-2 (2nd loop).

In order to dynamically pull the completed by user for the most recent loop, you can use the Field: Field Formulas action and for the Javascript code to calculate fields config field, you'll enter:
result = (run.tasks.find(t=>(t.taskName).indexOf('insert-task-name-here') > -1 && t.status === 'completed') || {}).completedBy || 'Not found';

  • replace insert-task-name-here with the name of the task for which you're trying to record the completed by user.

thanks to @Nicholas_797803 and @Aly_142377 for this one!

Comments

  • Meghan_550057
    Meghan_550057 Posts: 107
    edited October 2019

    Attached sample process export using the Field: Field Formulas action for recording audits of users completing a task with usage of a loop.