how to populate assigned to field in catalog task who approves that RITM

Deepika43
Tera Contributor

In my requirement, flow designer were created for the catalog item. Now,  the Assigned to field is populated with the name of the person that provided the approval. 
I tried with the script for assigned to field. But, not working as expected.

 

1 ACCEPTED SOLUTION

Hi @Deepika43

Can you please use the below script:

var sysId = fd_data.trigger.request_item.sys_id;
// pick the latest approver
var gr = new GlideRecord("sysapproval_approver");
gr.orderByDesc("sys_updated_on");
gr.addQuery("state","approved");
gr.addQuery("sysapproval", sysId);
gr.setLimit(1);
gr.query();
if(gr.next()) {
return gr.approver;
}

I hope this will solve your problem. Please mark it as Accepted and Helpful.

GoodWill,
Anshul

View solution in original post

13 REPLIES 13

@Ankur Bawiskar 
Okay, Let me try your solution as well.
Thanks and Regards
Anshul

Deepika43
Tera Contributor

var app = new GlideRecord('sysapproval_approver');

 

app.addQuery('sysapproval',current.sys_id);

 

app.addQuery('state',"approved");

 

app.query();

 

if (app.next()){

 

task.assigned_to = app.approver;

 

}

 

 

tried this too 

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepika43 

where in flow have you written the script?

share screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Deepika43
Tera Contributor

Deepika43_0-1694770117030.png

this is catalog task creation so here I added assigned to field with script expanded.

Deepika43_1-1694770224058.png

 

 

@Deepika43 

do this

var sysId = fd_data.trigger.current.sys_id;

// pick the latest approver
var gr = new GlideRecord("sysapproval_approver");
gr.orderByDesc("sys_updated_on");
gr.addQuery("state","approved");
gr.addQuery("sysapproval", sysId);
gr.setLimit(1);
gr.query();
return gr.approver;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader