How to get Previous value of record assignment

Supriya25
Tera Guru

Hi,

Please help me on below issue

 

SCTASK was Assignments changing as per situation, sometimes to groups, sometimes to Users.


Scenario 1 : Initially it was assigned to a user "David" , From David to it was assigned to Group : "Software", finally From Software group to it was assigned to "Hardware" group ( currently it was assigned to Hardware group).

Now I want to know that , to whom it was assigned Previously either group/user and it's value. (expected result: Software group ).

David-->Software group--->Hardware group .

 

Scenario 2: Initially  it was assigned to :Hardware group---> David user---> software group ( currently it was assigned to Software group)..
Now I want to know that , to whom it was assigned Previously either group/user and it's value. (expected result: David User).

 

Kindly let me know how to get this solved.

 

 

11 REPLIES 11

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Supriya25 

 

Give a try to metric table on sctask .

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi,

I tried to get data from sys_history_line.LIST

 

Supriya25_0-1703095732665.png

 

Supriya25_1-1703095774287.png

 

I tried below code

 

var gr = new GlideRecord('sys_history_line');
gr.addEncodedQuery('set=89c1652047937110e2192c44846d4368^field=assignment_group^ORfield=assigned_to');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
if(gr.next()){
gs.info("Field :"+gr.field);
}

 

getting Result like below :

Supriya25_0-1703097010457.png

 

 

here I'm getting current field value, bit how about we can get one step back

 

Going in Audit is complicated so SN provide the metrics.

 

LearnNGrowAtul_0-1703096768667.png

 

 

It will make your life easy and No code required. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

I understand , here we are looking at Metric table and telling that previously it was assigned to User Or group, clearly system showing , Perfect !. 

BUT  my concerns is 
how can we get that previous assignment value in-form of RESULT value from code  with Querying Metric table.

 

Please suggest !

 

Supriya25_1-1703098587636.png