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

Community Alums
Not applicable

Is the script returning any errors, or is it just not assigning the item correctly at all?



If i am not mistaken, I think you need to format your if statement containing the OR operator a little differently:



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




I am pretty new at this, but I just did something similar in a record producer and had to include the extra parentheses for my if statement to work correctly.



HTH,



Tim


Subhajit1
Giga Guru

Hi Madan,


Instead of using Display Value, you should try it with the actual value, and the comparison too should be done on actual values of the choice field.


Let me know if that helps.



Thanks,


Subhajit


Hi Subhajit,



No its not working.


if ((RoleType == '7100') || (RoleType == '11700') || (RoleType == '11900')){


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


                      current.assignment_group = 'SEC Adm VCE VMS';


                      gs.addInfoMessage(RoleType);



addInfoMessage is displaying the RoleType which i select for Choose Role but current.assignment_group is not setting the value.



I assume value is not setting.


You will have to use CatItem = gr.cat_item.getValue(); instead of CatItem = gr.cat_item.getDisplayValue();


Second, comparison should be on value as you did the 2nd time.


3rd, use current.assignment_group = 'sys_id of the Group you want set'.