Assigning a Request to a particular Group depending on Variable selected

RichardSaunders
Tera Guru

Hello, I have created a Catalogue Item called Operations (for arguments sake)

 

With a multiple choice variable set

 

  • Network
  • Security
  • Voice

 

Depending on what Variable is selected I want those particular variables to go to the corresponding Group. I know I could separate these into three separate items but we are trying to minimise the amount of Items in our Catalogue.

 

Is there simple way to do this or would anyone be able to help me advise on steps to script it?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Best   and very easy way is



system policy--->rules--->assignment---> NEW



APPLIES TO:


TABLE NAME: sc_req_item


CONDITION: item ---is---laptop



ASSIGN TO:


GROUP: SALES GROUP



click on     SUBMIT button


View solution in original post

6 REPLIES 6

Dan Tolgyesi1
Tera Expert

Hi Richard,



Just to confirm do you want the Request Item   to be assigned to a specific group or the Catalogue Task?



You could create an assignment group reference field that is hidden from the catalogue item form and then either using an onChange client script or a ui policy (using run script) you could populate the the assignment group field from this.



Your UI Policy could look something like: -




If FIELD_NAME is Network




Execute if true


function onCondition() {



      g_form.setValue('GROUP_REFERENCE_FIELD_NAME', 'GROUP_SYS_ID_GOES_HERE');


   


}



Execute if false


function onCondition() {



      g_form.setValue('GROUP_REFERENCE_FIELD_NAME', '');


   


}




IF YOU WANT TO ASSIGN THE REQUEST ITEM TO THE GROUP



Then in the workflow you could add a "run script" box and put the following code in: -



current.assignment_group = current.variables.ASSIGNMENT_GROUP;



This should then populate the assignment group field on the RITM



IF YOU WANT TO ASSIGN THE CATALOGUE TASK TO THE GROUP




On the catalogue task box on the workflow, select advanced so the script editor section appears and add the following code: -



{


task.assignment_group = current.variables.ASSIGNMENT_GROUP;


}



Hope this helps.



Cheers,


Dan


ProbirDas
Tera Expert

Hello Richard,



If I am not wrong, you are asking to set the Request's assignment group (and not Request Item's assignment group) based on the selection of the catalog item variable.



This can be done in the workflow itself (I suppose your workflow is created on sc_req_item). You can use use a 'Run Script' activity where you can check the variable value.



if ( current.variables.varName === "Network")


{


setAssignmentGrp("Network Group");


}


else if ( current.variables.varName === "Security")


{


setAssignmentGrp("Security Group");


}


else if ( current.variables.varName === "Voice")


{


setAssignmentGrp("Voice Group");


}



function setAssignmentGrp(grp)


{


var rec = new GlideRecord('sc_request');


rec.addQuery('sys_id',current.request);


rec.query();


if(rec.next())


{


rec.assignment_group.setDisplayValue(grp);


rec.update();


}


}




I haven't run and tried the code though, Please let me know how it goes.


Bhavesh Jain1
Giga Guru

Write an assignment rule on sc_req_item table.


See Defining Assignment Rules - ServiceNow Wiki



Script should be something like:


if (current.variable_pool.variableName == 'Network')


current.assignment_group.setDisplayValue('L2 Network Team');


else


if (current.variable_pool.variableName == 'Windows')


current.assignment_group.setDisplayValue('L2 Windows Team');


else


current.assignment_group.setDisplayValue('L1 Service Desk');


Best   and very easy way is



system policy--->rules--->assignment---> NEW



APPLIES TO:


TABLE NAME: sc_req_item


CONDITION: item ---is---laptop



ASSIGN TO:


GROUP: SALES GROUP



click on     SUBMIT button