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

Deepak Kumar5
Kilo Sage

If you change RITM state to in progress or something when Task assigned to someone then you can use RITM state is in progress for stop condition.


You have to make sure that user can't change state of task to anything else when assigning it to fulfiller.


Gowrisankar Sat
Tera Guru

Hi Ashley,



When a Task has been assigned in the sense, it is assigned to someone rather than assigned to group. Correct?



In that case, if you have Assigned To field available on sc_task form, just use this condition in Stop Condition -> Assigned To is not Empty.


The SN Nerd
Giga Sage
Giga Sage
  • Write a Business Rule/Client Wcript to set the TASK 'State' to "In Progress" when 'Assigned to' is not empty
  • Write an 'After Business Rule to set the RITM 'State' to 'In Progress' when a task is assigned.
  • Write your SLA with a Stop condition of 'Status' is "In Progress"

ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

knight202
Kilo Guru

Hi Ashley,



Can you post a screenshot of the SLA Definition? Please make sure to display all the conditions and the table you are firing against.



Also, is your task created manually or is it generated in the workflow? Thanks in advance!