Get previous from GlideRecord query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2015 09:35 PM
Is this possible to retrieve the previous values of a record from a GlideRecord query?
hypothetically:
var gr = new GlideRecord('sc_req_item');
gr.addNotNullQuery('sys_id');
gr.query();
var state;
if(gr.next()) {
state = gr.previous.state // Hypothetically this easy?
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2015 09:51 PM
Hi Daniel,
Previous can be used only to fetch the record before any changes were made, available on update and delete operations. This is not available on asynch operations.
http://wiki.servicenow.com/index.php?title=Scripting_in_Business_Rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2015 10:06 PM
Yes, understandable.
I was thinking of this more in a scheduled job or a background script than any business rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2015 03:05 PM
If you are looking for a Historical value of the particular field, say State in our case, you may definitely create a glide record, Query and hit the history Table with the details you want.
Refer the link below:
Viewing History Sets - ServiceNow Wiki