The CreatorCon Call for Content is officially open! Get started here.

Trigger Workflow Based on Catalog Item Selection in Order Guide

jmiskey
Kilo Sage

I have kind of a tricky situation which I am trying to figure out how to approach.

We have an Order Guide with three Catalog Items to choose from.  The Order Guide itself does not have a workflow attached to it.  2 of the 3 Catalog Items in my Order Guide do.  They are pretty straight forward, creating a single RITM, so those Workflows run off of sc_req_item and are available to be selected from the Workflow field on the Catalog Item.

However, my third one is a bit trickier.  It needs to create multiple RITMs, so the Workflow needs to run against sc_request so we can create multiple RITMs within that workflow.  However, when we create a workflow based on sc_request, it is not available to be selected from the Workflow field on the Catalog Item.  

I see from Workflow -> Properties -> Conditions, I could try to set a condition of which the workflow should run.  We have done this before, based on the Order Guide value.  However, that Order Guide was pretty straight forward and didn't have three different Catalog Items, each with their own workflow, listed underneath it.  So the Order Guide field,in and of itself, does not contain enough information regarding when the workflow should be called.  It is dependent upon the Catalog Item selected in the Order Guide (have a variable for that selection).

So, how can I do this?  How can I set up the Workflow for this third option to run off of sc_request and get it to be called when that third option is selected?

Thanks

1 ACCEPTED SOLUTION

This is what I have used to trigger new items from an initial item and added to the same request.

var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request,<sysID of the item>, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);

My use case:

We had an item that collected multiple share file locations, but needed individual approvals for each location.  My setup was an initial item that runs a script with this code in it to generate the individual items under the same REQ.  The original item closes automatically after the fact, so one 'item' spawns x number of individual items (dependent upon how many share file locations they request), all on the same REQ.

 

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=GlideappCalcHelperAPI

View solution in original post

35 REPLIES 35

Hey J, I'm actually trying to do something very similar to this myself.  In my case the original catalog item has a field with "|" separated lines and for each line I need to call a different catalog item with that lines information. 

So far I've got it to where the original ritm does create the new ritm, but it only creates it once and it doesn't pass the variables. 

Any thoughts on what I might be missing?