Assign Fulfillment Group Script

jcsmith
Kilo Contributor

Hopefully this is an easy fix.   I'm attempting to automatically fill the fulfillment group for a catalog task based on a selection in another field (which team).   I'm trying this line of code in the Script portion of the catalog task of the workflow:  

task.fulfillment_group = current.variables.infrastructure_team_select;

Anyone know why this wouldn't be working?   I'm not a developer and have zero scripting background, so I'm trying to dive into this a little bit at a time.

12 REPLIES 12

Hi Justin - I mean to say, on the catalog item definition, when you look at the variable, what is its type? Is it a reference to the sys_user_group table or is it a choice of some sort?


Oh, okay.   The variable is a Lookup Select Box type, looking up from a subset (using the reference qual field) of the Group table [sys_user_group].


Ah, then this is most likely your issue. We avoid the lookup select box in our instance, so what I'm suggesting here I'm not positive on. A couple ideas:



Add this line:


gs.info('InfrastructureTeam is ' + current.variables.infrastructure_team_select);


Then check the logs (all) for the note when you run it. This will give you an idea of what is being captured. I'm thinking you're getting the name of the group and not the sys_id, so your script can't set the task.fulfillment_group (you might want to double check this - fulfillment_group isn't out of box, so either you really want to reference assignment_group or u_fulfillment_group, if you added a custom field to the table).



You can try two things for setting the task group -



var gr = new GlideRecord('sys_user_group');


gr.addQuery('name',current.variables.infrstructure_team_select);


gr.query();


if(gr.next()){


task.assignment_group = gr.sys_id;


}



or you can try


task.setDisplayValue('assignment_group',current.variables.infrastructure_team_select);


Awesome.   I'll give that a try.   Thank you!!


I tried the easy one first - task.setDisplayValue('assignment_group',current.variables.infrastructure_team_select); - and that worked!!



Thank you so much for the help!