How to put assignment group recorded in oldvalue field from sys_audit ?

Sebastien C
Tera Expert

Hi,

 

After query to the right oldvalue, I can't put related assignment group to an incident:

 

var gr = new GlideRecord('sys_audit');
gr.addQuery('tablename','incident');
gr.addquery('fieldname','assignment_group');
gr.addQuery('documentkey',fd_data._2__look_up_record.record.sys_id);
gr.orderByDesc('sys_created_on');
gr.query();
if(gr.next()){
    var previousAssignmentGroup = gr.oldvalue;
}
return previousAssignmentGroup;
 
It records a random digit instead of the right assignment group sys_id in newvalue on sys_audit and the right assignment group name in the incident. 
I think I need to parse gr.oldvalue but I don't know exactly how.
 
Kind regards,
1 ACCEPTED SOLUTION

Sebastien C
Tera Expert

Thank you Chaitanya,

 

I found the way to put the assignment group by use a look up sys ID record  of the sys_user_group table and place the look up record in the assignment group field on the incident update record

 

Kind regards,

 

Sebastien

View solution in original post

2 REPLIES 2

Chaitanya ILCR
Kilo Patron

Hi @Sebastien C ,

var gr = new GlideRecord('sys_audit');
gr.addQuery('tablename', 'incident');
gr.addquery('fieldname', 'assignment_group');
gr.addQuery('documentkey', fd_data._2__look_up_record.record.sys_id);
gr.orderByDesc('sys_created_on');
gr.query();
if (gr.next()) {
    previousAssignmentGroup = gr.getValue('oldvalue');
}
return previousAssignmentGroup;

 

Try this with getValue()

 

if doesn't work please share the screenshots of what you are seeing

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Sebastien C
Tera Expert

Thank you Chaitanya,

 

I found the way to put the assignment group by use a look up sys ID record  of the sys_user_group table and place the look up record in the assignment group field on the incident update record

 

Kind regards,

 

Sebastien