Triggering RITM workflows

josh_tessaro
Giga Expert

We are not interested in doing any request (sc_request) level approvals at this time as everything will be approved at the Item (sc_req_item) level. We are starting to impliment workflows for some of our more complex items and are finding that the RITM workflow will not kick off until an approver/approval has been associated with the parrent request and marked approved. Simply changing the approval and state of the parent request does not seem to trigger the workflow of the child RITM.

I tried to find business rules/workflows that are making additional changes to either the parent Request or the child RITM when the Request approval is set but I could nt find anything. For context we are working toward implimenting a two step order guide (1. network account, 2. access items) using http://www.servicenowguru.com/system-definition/order-request-items-order-guide/

Can anyone shed some light on what we should be doing at the request level to trigger the child RITM workflows on Request submission?

21 REPLIES 21

sure... you can set an if in the workflow for if it is budget and the requested for is a manager you bypass the approval...



we also set it to auto approved for anyone with a VIP tag <the system puts them on vp's or higher>


sorry one other thing we did that may be better for you...



we put a variable on the item for requires managers approval...



in an onsubmit script we set the variable to yes by default.. we have this script in a variable set that contains the requested for and the approving manager <his manager> we add this to all items.. and if it doesn't require approval we set the variable to no.


Thanks again for the tips, this ended up making a lot of sense for us and I just finished implementing it, although I did it a bit different than you.




How it works:


1. Added fields to sc_cat_item and sc_request called u_manager_approval_required. these are True/False fields and the one on sc_request is locked down to only allow the system to write to it.


2. Set the new field to true on all catalog items that require manager level approval.


3. Added a business rule to sc_request that triggers on Insert, this rule checks all the child sc_req_item records for u_manager_approval_required and if it exists sets the same field to true at the sc_request level.


4. Modified the workflow to add a script that checks if the field is set to true and if it is checks if either the obened_by or rerquested_for is a manager in which case the sc_request is set to approved otherwise an approval is generated to requested_for.manager. If the field is false then the sc_request is approved.



This is working great, any request containing one or more requested items that need manager approval covers the manager approval in one email/approval record. Additionally this more clearly defines a two-tiered approval approach that we are implementing where many items require manager approval and then business/application owner approval.



The two step Orde guide for new hires is finished as well and does things that I would not have though possible. I'm definately liking the power of workflows!


How would you feel about sharing the contents of that BR and the workflow script I'm working on just about the same thing and scripting isn't my strong suit....


Bryan,



Here are the script pieces:



3. Added a business rule to sc_request that triggers on Insert, this rule checks all the child sc_req_item records for u_manager_approval_required and if it exists sets the same field to true at the sc_request level.




Business Rule Name: Calculate Manager approval


Table: Request [sc_request]


When: Before, on Insert


Script:


function onBefore(current, previous) {


  var item = new GlideRecord('sc_req_item');


  item.addQuery('request', current.sys_id);


  item.query();


  while(item.next()){


      if(item.cat_item.u_manager_approval_required){


          current.u_manager_approval_required = true;


          break;


      }


  }


}



4. Modified the workflow to add a script that checks if the field is set to true and if it is checks if either the opened_by or requested_for is a manager in which case the sc_request is set to approved otherwise an approval is generated to requested_for.manager. If the field is false then the sc_request is approved.



Here is a screenshot of our simple Service Catalog Request workflow as it stands now. The first IF contains the script below.


SS072.bmp



For the script portion you have to find a way to determine if the requested_for or opened_by is a manger in your organization. This could be a user attribute, whether they have reports or not or their title. An example with the title is below.



answer = ifScript();




function ifScript(){


  // if the request has an item that requires manager level approval...


  if(current.u_manager_approval_required == true){


  // if the requested_for or opened_by is a manager then manager approval has been met


      if(current.requested_for.title.toLowerCase().indexOf('manager') != -1 || current.opened_by.title.toLowerCase().indexOf('manager') != -1){


          return 'no';


      } else {


          return 'yes';


      }


  } else{


      return 'no';


  }


}