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

Robbie
Kilo Patron
Kilo Patron

Hi @servicenow14710,

 

The syntax used to call the scratchpad value looks correct. Thinking out loud based on your confirmation and checking the logs, there maybe inadvertent/accidental white space either at the start or the end of the value.

 

Can you try something similar to the below just to be sure:

 

var spAmsGroupValue = workflow.scratchpad.amsGroup;
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

Hello @Robbie : I tried trim the assignment group id , but it throws error. attached in screen shot.

@servicenow14710 

try to use toString() and trim

task.assignment_group =workflow.scratchpad.amsGroup.toString().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

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