Script for Catalog Task routed to particular assignment team

Jagadish10
Mega Expert

Hello Team,

I have a catalog item created. In the item description, I have created a workflow and attached to this particular catalog item.

Now, In the workflow, I have written a script to assign the task to particular assignment group based on the region populated on the task form.

Please note: Field 'Region' is one of the field on the task form.

Below is the code I have written, I'm not able to track the error in the code. Please help.

var America = US;

var reqForReg = current.request.u_region;

if(reqForReg==America)

{

task.assignment_group = 'Global Communications';

}

else {

task.assignment_group = 'Regional Communications';

}

Thanks

Jagadish

1 ACCEPTED SOLUTION

Hi Ashutosh,



I did go through the logs to find the bug, so that I can fix it. But it was difficult to read the logs and trace the error at right place.


So, I used the getDisplayValue() to avoid conflicts and it worked for me



I had to fumble as I'm new to writing scripts.



var america='US';


var region = current.task.u_region.getDisplayValue();


if (america==region) {


      task.assignment_group.setDisplayValue('Global Communications');


}


else {


  task.assignment_group.setDisplayValue('Regional Communications');


}



Thanks


Jagadish


View solution in original post

7 REPLIES 7

Great it helped.



Can close this thread by marking it as correct or helpful. This helps alot.



Thanks again


Harihara Sudha1
Kilo Expert

Hi Jagadish,



First, I would advice you to run your script in background with dummy variable values. Or else you can able to use log to find the errors of where your script failed to move.


gs.warn();


gs.log(); etc..


Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi Jagadish,



Assuming you wrote this script in Catalog task script section:



Please use quotes for US, see below:



var America = 'US';



Try this.



Thanks,