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.

Urgent!!!!!! Business rule to set auto assignment

madanm2103
Kilo Explorer

Hi All,

 

I have written a business rule to set the auto assignment group for Catalog Item.

But it is not workin....

 

Please help.

 

My requirement is, there is a choice field "Choose Role" which has some 30 values in my Catalog item.

If I select A or F or M for Choose Role, request item should assign to XYZ group, else should assigne to ABC group.

 

Below is my script.

var gr=new GlideRecord("sc_req_item");

gr.addQuery("sys_id", current.sys_id);

gr.query();

if(gr.next()){

      CatItem = gr.cat_item.getDisplayValue();

      //gs.addInfoMessage(CatItem);

      if (CatItem =='Demo')

              {

              var RoleType = current.variables.chooserole_vce1.getDisplayValue();

              //gs.addInfoMessage(RoleType);

              var grpname;

              if (RoleType == 'A' || RoleType == 'F' || RoleType == 'M')

              {

                      //gr.setValue('assignment_group', 'SEC Adm VCE VMS');

                      grpname = 'XYZ';

                      //gs.addInfoMessage(current.assignment_group.name);

              }

              else

              {

                      grpname = 'ABC';

              }

}

 

Please help, its urgent

 

Thanks in advance.

 

Thanks,

Madan

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

try this ...



condition : current.cat_item.sys_id == 'sys id of your catalog'



script:



var RoleType = current.variables.chooserole_vce1.getDisplayValue();


if (RoleType == 'A' || RoleType == 'F' || RoleType == 'M')


      {


      current.assignment_group.setDisplayValue('XYZ');


}


else


      {


      current.assignment_group.setDisplayValue('ABC');


}


View solution in original post

10 REPLIES 10

German Alvarez2
Tera Expert

Hi,



For improving your solution, I recommend you to check "System Policy" --> "Rules" --> "Assignment" module. (at [sysrule_assignment] table)



I think this is the right place to do this.



I hope it will help you.



Best Regards