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

anshul_goyal
Kilo Sage

Hello @Deepika43,
Kindly share your script.
Thanks and Regards,
Anshul

// Get the name of the approver
var approverName = gs.getUserName();

// Get the current task (you may need to customize this based on your workflow)
var currentTask = current;

// Set the Assigned To field to the approver's name
currentTask.assigned_to = approverName;

// Update the task
currentTask.update();

Hi @Deepika43,

Use the below script in the Custom Action in Flow Designer: 
var approverRef = new GlideRecord("sysapproval_approver");
approverRef.addQuery("state", "approved");
approverRef.addQuery("document_id", inputs.ritmSysID);
approverRef.query();
if (approverRef.next()) {
outputs.approveduser = approverRef.approver;
}

Anshul21_0-1694770627805.png

 

Anshul21_1-1694770670179.png

 

Anshul21_2-1694770708086.png


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

GoodWill,
Anshul

@anshul_goyal 

Custom action is not necessary here.

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