- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2019 03:32 AM
Hi Team,
I have a requirement to close bulk records where the current state is "open" and the previous state is "closed complete".
I am unable to get the previous value of the field in fix script.
Is there any possible?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2019 03:49 AM
Hi,
You can use sys_audit table to get old value. But this table is very big in the number of rows and might affect the performance of the system.
I have provided the code for 1 user earlier which fetches the incidents based on old value. check the replies and you will find the code in this question.
You can use that as reference and can modify as per your requriement.
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2019 03:38 AM
Hi Gokulraj,
Directly it is not possible.
If the table is audited then you can get the details from history table i.e. for particular field what is current value and what is previous value
go to sys_history_line.list
search with lable as your field name
add query for old value as closed complete and new value as open
and set.table as your table name
sample url below: I have taken incident table for example:
https://instanceName.service-now.com/sys_history_line_list.do?sysparm_query=set.table%3Dincident%5Elabel%3DState%5Eold%3DClosed%20Complete%5Enew%3DOpen
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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-25-2019 03:49 AM
Hi,
You can use sys_audit table to get old value. But this table is very big in the number of rows and might affect the performance of the system.
I have provided the code for 1 user earlier which fetches the incidents based on old value. check the replies and you will find the code in this question.
You can use that as reference and can modify as per your requriement.
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2021 05:41 AM
There is now an API for this.