How to update RITM in workflow scripts

peter_repan
Tera Guru

Hi all,

I would like to use Run Script activity in Workflow for updating RITM field based on some script logic.

I'm using current.update(), but when I validate or publish workflow, I got following warning:

ValidateScriptForCurrentDotUpdate

This workflow uses 'current.update()' in 1 JavaScript statements. When a record is inserted, current.update() can cause the workflow   to execute   an infinite loop. When a record is updated, current.update() causes all script engines to run twice. To avoid an infinite loop when a record is inserted, remove unnecessary current.update() calls from custom scripts.

The behavior of workflow is strange, because for each requested item I'm getting now two workflow instances (of the same workflow).

Is there any way/workaround how to update RITM in workflow scripts?

1 ACCEPTED SOLUTION

Hi Peter,



If you have created workflow on the RITM table then you can directly update the fields in a run script activity. Just add



current.ritm_field_name = current.variables.variable_name;



If the workflow is on a different table like request, then you need to first fetch RITM via Glide query.



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


View solution in original post

9 REPLIES 9

good to know, but do you know about any other way how can I update RITM in workflow? (without using Set Value activity, because it's not possible to write script logic in this activity)


Hi Peter,



If you have created workflow on the RITM table then you can directly update the fields in a run script activity. Just add



current.ritm_field_name = current.variables.variable_name;



If the workflow is on a different table like request, then you need to first fetch RITM via Glide query.



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Hi Alikutty,



you are right. I don't have to call current.update(), because if I use Run Script activity it updates RITM automatically. I found it also in documentation



Note: All changes to current are automatically updated. There is no need to call current.update()



I did not know this before.


However what's still happening is that I have two instances of workflow.


Couldn't find a reason why....


Are they 2 instances of same workflow or different once? Did you check the workflow names



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Hi Alikutty,


they are instances of the same workflow. I created new question for this issue:



Usage of Timer activity creates two workflow contexts