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

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.


Thank you Mani. I have been able to get this working now. The only issue I am having is I am trying to remove these new options from the choice list unless the task has a certain assignment group (Revenue Cycle Management). My client script it below. Do you have any suggestion as to why this is not hiding the options?



function onLoad() {


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


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


  var rcm = "Revenue Cycle Management ";



  if (group != rcm){


  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');


  }


   


}




It appears that it is always evaluating to true and hiding the option all of the time. Is there a problem with my var group call to get the assignment group? I think it is coming back empty.



Thanks


Only explanation is that the control isn't going into the `if` loop. I see a space at the end of the declaration   var rcm = "Revenue Cycle Management ";



Can you put an alert and see if it's going inside the if loop? Also remove the space if you think it is not needed.


jordanr
Tera Contributor

I added the alert to check if it was entering the loop and it executed. It also says it was returning a type of object. This led me to try and add the toString() to my if statement and it is still not working. Any other thoughts?? The new code I tried was:


function onLoad() {


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


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


  var rcm = "Revenue Cycle Management";



  if (group.toString() != 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');


  }


   


}