Fulfillment workflow script to assign fulfillment group based on requester select application

bbf3562
Kilo Guru

I want to make a script in fulfillment workflow that will assign specific fulfillment group depend on which business application the requester input(reference field). I have business application table(u_business_applications) where it has fulfillment group field called u_fulfillment_group. Here is screenshot of workflow,

find_real_file.png

In "Set Assignment Group", is this the correct code to get fulfillment group value from business application table based on requester choose business application name in reference field(business_application) and then assign it?

find_real_file.png

1 ACCEPTED SOLUTION

If that's the scenario then use the below script directly in create task run script



var gr = new GlideRecord('u_business_application');
gr.addQuery('sys_id', current.variables.business_application);
gr.addQuery('enabled', true);
gr.query();


while(gr.next())
{


task_glide_record.assignment_group = gr.u_fulfillment_group;


}



you need to update "task_glide_record" in the above script


View solution in original post

12 REPLIES 12

Deepa Srivastav
Kilo Sage

couple of corrections. give the var other than gs as it represent Glide system API and may cause some confusion.


Put while loop after gr.query. are these reference variable or string? if ref you need to compare sys_id in add query instead of name..pls chk the link.


var name=currrent.variables.business_application;


var gr=new GlideRecord('u_business_application')


gr.addQuery('name',name);


gr.query();


while (gr.next())


{ ...your code


}


GlideRecord - ServiceNow Wiki




Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy


I am not update anything in table which I don't need to do gr.update(); because I just want to get fulfillment group value from table and assign as current assignment group. I am not sure you asking about reference variable or string but that business application field is reference field with magnify glass to display list for user to select name of business application to populate name in field. I am not sure if I need to get sys_id variable instead of string application name? I just updated my screenshot with code in case you haven't seen it.


Are you trying to set assignment group on request item or catalog task?


I believe it catalog task because it a fulfillment group that do the task to add user access to application the user requested.