We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to access previous value of "state" field in workflow

Roshani
Tera Expert

Hi All,

I have a workflow running on HR payroll table . I want to set the "state" field to its previous value . How can I write in workflow . Below code i am using now, its seems not working 

current.state = workflow.scratchpad.state;
current.update();

10 REPLIES 10

Sukrit
Giga Contributor

Hi Roshani,

Use a run script in workflow and save the state value before it changes in a scratchpad, using:

 workflow.scratchpad.state = current.state;

Now you can access this value anywhere in the workflow using 'workflow.scratchpad.state'.

Thanks