- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 01:34 AM
Hi,
can any one guide how to assign an approver by using script in work flow(run script)
I had written some code, pls check and tel me if am wrong
var desc = task.description;
var startDate = current.variables.colleague_start_date;
if(startDate != null && startDate != ''){
task.description = "Colleague Start Date: " + startDate + "\n\n" + desc;
}
if(current.variables.u_emp_site == "u_hgstsz" && current.variables.u_items == "u_laptop")
{
current.sysapproval_approver.approver= "0526160bb4c6f500b47b0c26378dccee";
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 01:52 AM
1) Create a IF conditional activity to check the condition
answer = ifScript();
function ifScript() {
if (current.variables.u_emp_site == "u_hgstsz" && current.variables.u_items == "u_laptop") {
return 'yes';
}
return 'no';
}
2) Then connect the Yes flow to an Approval User activity in your workflow with below code in it to generate approval to a specific user.,
answer = [];
answer.push('0526160bb4c6f500b47b0c26378dccee'); // sys_id of the user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 10:19 PM
Hi Guhan,
thank you very ,much for your support, as u guided i have created an custom table and created an approval group in that i had written script in advanced script as below, also pls find the screen shot of my work flow and scirpt below.
answer = [];
var gr = new GlideRecord('u_it_service_request_nrp');
gr.addQuery('u_emp_site',current.variables.u_hgstsz);
gr.addQuery('u_item',current.variables.u_laptop);
gr.query();
if(gr.next()) {
answer = gr.Ping Zhou;
}
please tell me if i am anything wrong

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 10:28 PM
Hi Prabhakar,
Can you try the below script once. Just make sure that your variables names are correct.
//Initialize an answer array to be returned
var answer = [];
var gr = new GlideRecord('u_it_service_request_nrp');
gr.addQuery('u_emp_site', current.variables.u_hgstsz);
gr.addQuery('u_item', current.variables.u_laptop);
gr.query();
while(gr.next()){
answer.push(gr.Ping Zhou); //Please make sure that Ping Zhou is the exact name of the catalog variable
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 11:20 PM
Hi pradeep,
Ping Zhou is the user name need to assign for approval

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 11:22 PM
Little confused. So you want to hard code the user for approval?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2016 11:38 PM
pls find the screen shot, requirement is like if user selects
(1)HGSP-laptop-request should go to approver1
(2)HGST SZ-laptop-request should go to approver2
(3)HGST SZ-laptop-request should go to approver3
(4)HGSP-Hardware-request should go to approver4
(5)HGST SZ-Hardware-request should go to approver5
(6)HGST SZ-Hardware-request should go to approver6
like that based upon the "site" field selection and below check box selection the approver will change.
hope u got it pls suggest me