How to set assignment group from a Catalog Item

jmbrake
Kilo Expert

I have a catalog item called "Self Assigned Task".   I have created a Reference field called "AssignGrp" for this catalog item, which looks up the assignment groups.   I would like to take the group selected during the Request process and have it follow through to the Task.   I am using a workflow to populate other fields down to the Task level, but I cannot get the Assignment group to pass to the task.   The top two lines work fine, the last one does not.   Any help would be appreciated

task.short_description = 'Perform this   ' + current.cat_item.getDisplayValue();

task.description = 'Perform this ' + current.cat_item.getDisplayValue();

task.assignment_group = current.variables.AssignGrp;

1 ACCEPTED SOLUTION

Hi Joan,


Could you try to find out if any other script is forcing blank value?


Might be some other business rule.



You can use field watcher for debugging purpose


http://wiki.servicenow.com/index.php?title=Field_Watcher#gsc.tab=0


View solution in original post

16 REPLIES 16

Deepak Ingale1
Mega Sage

Hi Joan,


syntax to access variables.



current.variables.variableNameGoesHere ;



Now in your code, please check if 'AssignGrp' is variable Question field or it is a name?


You need to type the field name.


If that still does not work, try to add below line


current.variables.variableNameGoesHere.toString();



find_real_file.png


I am using the Name field.   Even with your added code, it did not work.   I tried your additional code above and below the task.assignement_group line




task.short_description = 'Perform this   ' + current.cat_item.getDisplayValue();


task.description = 'Perform this ' + current.cat_item.getDisplayValue();


current.variables.assigngrp.toString();


task.assignment_group = current.variables.assigngrp;


Hi Joan,


Could you try to find out if any other script is forcing blank value?


Might be some other business rule.



You can use field watcher for debugging purpose


http://wiki.servicenow.com/index.php?title=Field_Watcher#gsc.tab=0


This did not help me find the problem either.   It did not show any value getting set.   I have tried Debug ALL also and still can't find the issue.   I went a step further and created a new field called AssignTo and used a similar workflow script line to populate the person names instead of doing the assignment group and it works.   This leads me to believe it is a Business Rule or Assignment Group.



I only have two Active Assignment Rules:  


  Table - ticket - SC Items Fulfillment - Field Services


&


Table - Release Phase - Release Planning



I don't think either of these are my issue.



How can I narrow it down to the assignment group?   I have one rule called BackfillAssignment Group, code below



function BackfillAssignmentGroup() {


var gp = ' ';


var a = current.assigned_to;


//return everything if the assigned_to value is empty


if(!a){


return 'typeLIKEc8e63e022129f00014b873c26235c749^ORtype=null';//sys_id of the Group Type filtered for assignments (only show those of this type)


}


//sys_user_grmember has the user to group relationship


var grp = new GlideRecord('sys_user_grmember');


grp.addQuery('user',a);


grp.query();


while(grp.next()) {


if (gp.length > 0) {


//build a comma separated string of groups if there is more than one


gp += (',' + grp.group);


}


else {


gp = grp.group;


}


}


// return Groups where assigned to is in those groups we use IN for lists


return 'sys_idIN' + gp + '^typeLIKEc8e63e022129f00014b873c26235c749^ORtype=null';


}



This is the rest of the list of Business Rules that have "assign" in the name.




Capture3.PNG


I just want someone to clarify if I did this right.   The Business Rule "BackfillAssignmentGroup" was Global and was the PROBLEM.   I made it inactive.   Then I took all of the code from it and put it into a Script Include.  



We were using this Business Rule against the Incident and Change Modules and may be others.   Will the Script Include need to be more defined to work with specific tables or is it fine as is now.



Thanks to all for leading me in the right direction.