Set watch list with business rule

petterbj_rgmo
Tera Contributor

Hello all,

We are on Helsinki and using inbound actions with the Service Desk Call plugin. In the inbound action I created I am adding a email address to the watch list on the Call form. When the Call type is set to request, I need the email address on the watch list to be added to the watch list on the request item. So basically I want the email address in the watch list to be added to the RITM when it is created. I have tried doing this with a business rule (after) that runs on insert and is run on the sc_req_item table. The code is as follows:

find_real_file.png

I cannot seem to figure out where I am going wrong. Any ideas?

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Here you go. Use this script. This should be a before business rule



var gr1= new GlideRecord("new_call");


gr1.addQuery("transferred_to",current.getValue("request"));


gr1.query();


if(gr1.next()){


current.watch_list=gr1.u_watch_list;


}


View solution in original post

21 REPLIES 21

It contains a reference to the record that the call is transferred to. So in this case it reference to the REQ, not to the RITM.



find_real_file.png


I have written this script in the RITM table and it works fine for me(Before insert/update type business rule).



function onBefore(current, previous) {


    //This function will be automatically called when this rule is processed.


   


  var gr1 = new GlideRecord('new_call');


  gr1.addQuery('transferred_to',current.request);


  gr1.query();


  if(gr1.next()){


  current.watch_list = gr1.u_watch_list;


  }


}




Thanks,


Mihir


So, just to be clear. You are creating a Call record, setting Call Type = Request and choosing a Request item. Then you go to the request, and further more to the RITM. On the RITM the email on the watch list from the call record is in the RITM watch list? Is this the case? If yes, then I am not sure what is not setting my watch list. Just tested the same code you gave me. No luck


1.I have created a call list record.Added a user in u_watch_list field and a REQ number in the transferred to field.



2.Then I have opened the REQ number that is attached in the Call record.Opened the RITM record that is attached with this REQ.


And modified some value in the RITM form (as the business rule is before insert/update type after updating any field in the RITM form it will run).


Then the user I have selected in the u_watch_list field copied in the watch_list field of the RITM form.



make sure u_watch_list field in the Call table is referenced to sys_user table then the script I have provided to you will work.



Thanks,


Mihir


Do you think it will work by adding a custom email address, and not a ServiceNow user?


Like; adding "external.user@domain.com" and not "Abel tutor"?