Get previous from GlideRecord query

kungfuu72
Giga Expert

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?

}

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

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


Yes, understandable.



I was thinking of this more in a scheduled job or a background script than any business rules.


ashish68
Kilo Expert

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