How to access previous value of "state" field in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 01:54 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:02 AM
Hi Roshani,
Simply use previous.state directly whenever you want to set it.
Please mark helpful & accept the solution if it solves the purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:19 AM
you cannot access previous object in workflow
it only works in business rules
1) store the value before you update in workflow scratchpad and then use it
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2021 02:22 AM
another option to get the previous value is using sys_audit table which stores the information
script help check below link
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader