Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unable to assign assignment group to catalog task dynamically through workflow

servicenow14710
Tera Expert

Hello developers,

 

 

i want catalog task to get assigned to various groups based on configurations on UI. i have stored  the assignment group in a scratchpad variable, when im trying to assign it to catalog task 

task.assignment_group =workflow.scratchpad.amsGroup;
it is not working , i have checked with logs the scratchpad stores the sys id.
But when i give the sys id directly it is working
task.assignment_group ='sys_id'.
can someone please help me here as where the issue is?
Any help is appreciated, Thanks!
1 ACCEPTED SOLUTION

Hi @servicenow14710,

 

Hmmm, interesting, but this may also point to the issue in that you're actually retrieving an object. Obviously, without first-hand sight, these are just thoughts out loud.

 

See and try the below slight tweak.

 

var spAmsGroupValue = workflow.scratchpad.amsGroup.toString(); //converting to a String object
var tskAmsGroup = spAmsGroupValue.trim(); //removing any white space

task.assignment_group = tskAmsGroup;

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@servicenow14710 

are you sure there are no leading and trailing spaces in that scratchpad variable?

print the value and then try to use trim() method to see if that works

I agree with @Robbie here

gs.info('group is' + workflow.scratchpad.amsGroup);
task.assignment_group =workflow.scratchpad.amsGroup.trim();

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

Thanks for the validation @Ankur Bawiskar.

Feel free to mark my response helpful in order to help others and for me to gain recognition of my efforts.

 

Thanks, Robbie

-O-
Kilo Patron

> i have stored the assignment group in a scratchpad

Can you show the code how you do that?