Set assignment group in SC_Task from variable referencing sys_user_group table

Doug Julian
Giga Expert

We are trying to create a catalog item for internal use for our security team. the request does not have a defined assignment group and is selected by the user via a Variable on the form. 

DougJulian_0-1668201757307.png

 We are trying to set the task.assignment_group field to the value in our assignment_group variable. Both fields are reference fields using the sys_user_group table but i suspect that there is some additional code i need to deal with labels vs sys IDs or something similar. 

 

Current Script

task.assignment_group = current.variables.assign_to_group;

DougJulian_2-1668202352602.png

 

current result: Field is empty or has an invalid hidden sys_id

DougJulian_1-1668202294476.png

my hope is to avoid looping through an if statement for each assignment group as we have close to 200

Thanks in advance!

 

1 ACCEPTED SOLUTION

Logan Poynter
Mega Sage
Mega Sage

Hello,

Is there a reason you need to utilize a Lookup Select Box rather than a Reference variable?

Is your variable on your form actually called "assign_to_group" or do you have another name? 

 

You want to make sure that you're getting the group sys_id and setting that as the value for the assignment group and a reference field would be the usual option. Your lookup select is going to be returning the display value of the group chosen (i.e. the name). 


Please mark my answer as correct/helpful if it has helped you.

Thanks,
Logan
--
LinkedIn 

View solution in original post

3 REPLIES 3

Logan Poynter
Mega Sage
Mega Sage

Hello,

Is there a reason you need to utilize a Lookup Select Box rather than a Reference variable?

Is your variable on your form actually called "assign_to_group" or do you have another name? 

 

You want to make sure that you're getting the group sys_id and setting that as the value for the assignment group and a reference field would be the usual option. Your lookup select is going to be returning the display value of the group chosen (i.e. the name). 


Please mark my answer as correct/helpful if it has helped you.

Thanks,
Logan
--
LinkedIn 

Logan thanks for the quick reply.

Why we use lookup select box: due to how the form handles it as a drop down vs popup window

assign_to_group is the variable name on the form yes 

 

I tested using Reference Variable instead of Lookup and it immediately started working with the current script.

I assume those two types handle the value that its sending to the field differently in the back end.

 

The reason however that we were using the Lookup Select box was because the form treats it as a drop down while the Reference is treated as a popup window. We have had some users in the past who have issues with popups for various reasons so by default we tend to avoid any variable type that forces a popup. 

 

For now im going to stick with using Reference Variable as this works and will work for this particular use case though I would like to know if theres a way to make it work as a dropdown vs popup.

 

Thanks!

Gotcha, change the value to sys_id and add the name field as the lookup label field - that should do the trick for you.