Requested Item SLA

aeb5468
Mega Contributor

Hi Everyone!

I have been working on SLAs for the request item level in our instance. I have the SLA starting and pausing when needed. The problem I am having is that I want to have the SLA end when a TASK (this TASK will always be one that is open for the Requested Item) has been assigned. I have tried business rules, UI actions, and client scripts and none have helped with populating data from the TASK up to the requested item. I also can't pull the TASK.assigned_to using the selections on the SLA definition. I just wanted to see if anyone has had any experience with this.

Thank you so much!

Ashley

1 ACCEPTED SOLUTION

aeb5468
Mega Contributor

I got this code working:



(function executeRule(current, previous /*null when async*/) {




var kids = new GlideRecord ('sc_task');


kids.addQuery('request_item', current.request_item);


kids.query();


                           


//gs.addInfoMessage("This is requested item number: " + current.number);


//gs.print("This is the requested item number: " + current.number);




while (kids.next()) {


  var parent = new GlideRecord ('sc_req_item');


  parent.addQuery('sys_id',kids.request_item);


  parent.query();


                                             


  while (parent.next()) {


      //gs.addInfoMessage("This is a test: " + parent.number);


      //gs.print("This is a test: " + parent.number);


      //gs.addInfoMessage("backordered before: " + parent.u_sla_state);


      //gs.print("backordered before: " + parent.u_sla_state);


      //gs.addInfoMessage("SLA " + kids.u_sla_progress);  


            if (kids.u_sla_progress == true ) {


                    parent.u_sla_state.setValue('true');


                    parent.update();


                    //gs.addInfoMessage("backordered after: " + parent.u_sla_state);


                    //gs.print("backordered after: " + parent.u_sla_state);


          }


    }


}                                            


})(current, previous);


View solution in original post

24 REPLIES 24

aeb5468
Mega Contributor

Hi everyone!



So I have decided that the business rule method to have the requested item check the open tasks for SLA Progress set to true which will then set the Value of SLA state to true. The dot walk method in business rules did not work, so I was wondering if anyone has any experience in debugging code because mine is not working.


Business Rule:


When to run:


Filter is Active is true.



Advanced Script:


(function executeRule(current, previous /*null when async*/) {



var kids = new GlideRecord ('sc_task');


kids.addQuery('sc_task.number', current.sc_requested_item.number);


kids.query();


while (kids.next) {


if (kids.u_sla_progress == 'true') {


current.u_sla_state.setValue('true');


}


}



})(current, previous);


Script should be like :



var kids = new GlideRecord ('sc_task');


kids.addQuery('request_item', current.sys_id);


kids.query();


while (kids.next) {


if (kids.u_sla_progress == 'true') {


current.u_sla_state= true;


}


}


This didn't work. This is what my BR setup looks like:


find_real_file.png


find_real_file.png


find_real_file.png


Something weird to note is that the Actions tab isn't firing either. The requested item is not having it's description trigger, so I am not sure if my when to run is correct.


I'm puzzled as to why you need/are messing around with BRs. The SLA Definition needs to be edited.


The SLA definition cannot dot walk to the Task. The SLA is on the requested item level. I need the SLA to end when a field on the Requested Item is changed due to a task field changing to True.