workflow

nameisnani
Mega Sage

HI team , 

 

need help in script 

 

I have a catalog item called ' SWA AD '

in that we have reference field ' Application Name ' which refers to cmdb_ci_service_auto table .

approvals has to trigger to the application service >> approval group

nameisnani_1-1758009186706.png

 

 

As this is old catalog already WF configured . 

So i am trying to achieve via script 

my scipr is not working 

please help me what was the mistake 

 

(function executeRule(current, workflow) {
    var groupId = "";
    if (current.u_application_name) {
        var app = new GlideRecord("cmdb_ci_service_auto");
        if (app.get(current.application_name)) {
            groupId = app.change_control; // adjust field name
        }
    }
    workflow.scratchpad.approvalGroup = groupId;
    return groupId;
})(current, workflow);

nameisnani_0-1758009031338.png

 

 

could you please prrovide me the updates script 

 

@Ankur Bawiskar 

7 REPLIES 7

M Iftikhar
Mega Sage

@nameisnani ,

Pass .toString() when using get() on a reference field.  -> app.get(current.u_application_name.toString())

Try maybe it will work!

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.

Ranjit Nimbalka
Mega Sage

Hi @nameisnani ,
Try Below script

(function executeRule(current, workflow) {
var groupId = "";
if (current.u_application_name) {
var app = new GlideRecord("cmdb_ci_service_auto");
if (app.get(current.u_application_name)) {
groupId = app.change_control;
}
}
workflow.scratchpad.approvalGroup = groupId;
return groupId;
})(current, workflow);

 

Regards,

Ranjit Nimbalkar

@Ranjit Nimbalka  not worked

 

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

update as this in your workflow advanced script for approval activity

answer = [];

answer.push(current.variables.u_application_name.change_control.toString()):

Approval - Group workflow activity 

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