
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 10:42 PM
Hi,
I try to query the sys_audit table to get an old value from a specific field. My proble is the documentkey field. In this field is stored the sys_id from the record. When I use the sys_id directly, I got my result. When I use g_form.getUniqueValue(), I got no result. I use this code:
//var dockey= 'c623ccd3db625bc4dcaefe9b0c961958'; (sys_id from the record)
var dockey = g_form.getUniqueValue();
var olddx = new GlideRecord('sys_audit');
olddx.addQuery('tablename', 'u_kodak_dx_numbers');
olddx.addQuery('fieldname', 'u_location');
olddx.addQuery('documentkey', dockey);
olddx.query();
while(olddx.next()) {
alert(olddx.oldvalue + ' dx audit');
}
Have anybody an idea where my mistake is?
Best regards
André
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 11:26 PM
Ok. You can easily do that using an After update business rule.
For ex if you changed the location, you can use
gs.addInfoMessage('+++current location++++'+current.u_location);
gs.addInfoMessage('+++old location++++'+previous.u_location);
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 10:44 PM
Are you using a client script? Because g_form.getUniqueValue() will only work on client script.
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 11:09 PM
yes I´m using a client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 11:13 PM
Can you tell me the reason you are using a client script. What is the use case?
I would suggest not querying the sys_audit table from client script, because it is a huge table and it can slow down the performance. Instead use an async business rule. But depends on what you are trying to do.
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2018 11:22 PM
Okay, the use case is: If I delete an entry in a specific field on a form, I have to set back a specific value on another table to the old value after saving. Therefor I need the old value from this deleted entry because thats the reference to the other table.