Get the date when the state was changed to "Approved"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 07:59 AM
Hi,
I need to get the date when the "State" of the record was changed to "Approved".
I created a Business Rule to capture the date in a Date field when the state changes, but for old records is there way to get the date. I tried GlideRecord for "sys_history_line" table but that does not work.
The state does not change from the sysapproval_approver table. It is changed when required users sign a document via a 3rd party integration.
PS: I can see the date in the Work Notes.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 08:19 AM
When you are glide recording sys history line table instead of checking set=sysid Check set.id=sysid of the incident or ritm.
Feel free to mark correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 10:22 AM
Yes, I used seet.id=the sys_id of the record.
The thing is, the table had around 60 records and it returned only the dates for around 15 records. For others, it showed undefined. Though if I open the record and view its history, it's there.
var seh = new GlideRecord("sys_history_line");
seh.addQuery('set.id', se.sys_id);
seh.addEncodedQuery("label=State^new=Approved");
seh.query();
if (seh.next()){
up = new GlideDateTime(seh.update_time)
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 10:31 AM
Instead of quering sys_history_line why not take updated time of the record.
I am assuming when record is Approved that will be the final update that has happened on the record.
Something as below
var approvalis=new GlideRecord('sysapproval_approver');
approvalis.addQuery('state','approved');
approvalis.query();
while(approvalis.next())
{
gs.print('Record was approved at '+approvalis.sys_updated_on.getDisplayValue());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2022 10:39 AM
The state does not change from the sysapproval_approver table. It is when required users sign a document via a 3rd party integration.