Adding Custom state values for catalog tasks

jordanr
Tera Contributor

I have been asked to add new choice options for the state field of catalog tasks.   I have gone to the catalog task form and added the options and given them each a value (9-15). When closing these tasks we want the new choice that is selected to display rather than the standard 'Closed complete'. Also when the new choice is selected we need the task close the associated RITM and Request.

For Example:

I have a new choice option called ' Payment Posted' with the value of 12. I adjusted the "Close Ticket" Business Rule condition on the sc_task table to set the active status to false when the state value changes to 12. This is working fine and when I update the task it is no longer active and the closed field is populated. However, the RITM and Request are not closing.

I tried adding the new value to my wait for condition in the workflow as seen below:

answer = true;


var gr_tsk = new GlideRecord("sc_task");

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

gr_tsk.addQuery('state', '!=', '3');

gr_tsk.addQuery('state', '!=', '4');

gr_tsk.addQuery('state', '!=', '7');

gr_tsk.addQuery('state', '!=', '12');

gr_tsk.addQuery('wf_activity', '');

gr_tsk.query();

if (gr_tsk.next()) {

    answer = false;

} else {

    answer = true;

}

We have a set values activity that was setting the state to 'closed complete' , but I removed this condition since I want the value that was selected to remain.  

Does anyone have advice on what else I need to adjust to   get my RITM stage to change from fulfillment to complete when the task is closed with the new state value?

I appreciate any help on this.

Jordan R.

1 ACCEPTED SOLUTION

manikorada
ServiceNow Employee
ServiceNow Employee

Jordon,



There is a business rule which will kick the Workflows on RITM when Catalog Task is closed. The Business rule is 'SNC - Run parent workflows'.URL Is https://<instance_name>>.service-now.com/nav_to.do?uri=sys_script.do?sys_id=98412b3d0a0a0b88652919d1ff714e1d



Mimic the same business rule to run on Catalog Task when State is changed to your required values. So, now this custom business rule will invoke the Workflow on RITM when the Catalog Task is closed with your custom states.


View solution in original post

9 REPLIES 9

Ah I got the issue. I'm sorry. Assignment group is a reference. Change the name of the Group with the sys_id of the group, it should work fine.


manikorada
ServiceNow Employee
ServiceNow Employee

Jordon,



Have the script as something like this:



function onLoad() {


    //Hide RCM Resolve code options for tasks unless assignment group is RCM.


  var group = g_form.getReference('assignment_group');


  var rcm = "Revenue Cycle Management";



  if (group.name != rcm){


// alert(typeof g_form.getValue('assignment_group'));


  g_form.removeOption('state','9');


  g_form.removeOption('state','10');


  g_form.removeOption('state','11');


  g_form.removeOption('state','12');


  g_form.removeOption('state','13');


  g_form.removeOption('state','14');


  g_form.removeOption('state','15');


  }


 


}


I think the best practice is to use a call back with g_form.getReference, below is how to use a callback with g_form.getReference();



function onLoad() {


     


      //Hide RCM Resolve code options for tasks unless assignment group is RCM.


     


      var group = g_form.getReference('assignment_group',callbak);


     


      var rcm = "Revenue Cycle Management";


     


      function callbak(group){


              if (group.name != rcm){


                     


                      // alert(typeof g_form.getValue('assignment_group'));


                      g_form.removeOption('state','9');


                      g_form.removeOption('state','10');


                      g_form.removeOption('state','11');


                      g_form.removeOption('state','12');


                      g_form.removeOption('state','13');


                      g_form.removeOption('state','14');


                      g_form.removeOption('state','15');


              }


      }


     


}


I have tried this fix, but my tasks are still not being closed with my custom states. Help?!


jordanr
Tera Contributor

Thank you to both Mani and Abhiram!! Your suggestions have helped to get this working as desired. I appreciate the help.