- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:16 PM
I'm using an Inbound Action to create a Request and a single RITM under it.
Everything got created and worked as expected. The REQ workflow triggered as soon as the record was created, once approved, the RITM workflow triggered and created catalog tasks as expected.
Then I threw a wrench into it and it broke. The requirement was that this particular item is a trivial request and should NOT generate any approvals on the REQ level and we simply need the catalog tasks created. So here was my approach: In the Inbound Action, I set the Request's approval state as "Approved". In the Request workflow, I set the condition to fire only when the Approval stat is no "Approved". So now, when the Inbound Action creates the REQ and RITM, the REQ Approval State is "Approved" as expected, and there's no workflow firing on the REQ, as expected. HOWEVER, the RITM doesn't fire a workflow either, so the needed catalog tasks are not getting created.
How can I make this work to meet my requirement? If I can make the RITM workflow fire somehow, I believe it would work.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 01:37 PM
Found a solution from this article: Request Generation Methods — ServiceNow Elite
Added the following into my Inbound Action:
var w = new Workflow();
wfSysId = w.getWorkflowFromName("workflowName");
var context = w.startFlow(wfSysId, current, current.operation());
if (context != null){
current.context = context.sys_id;
current.update();
}
That triggered the needed workflow and associated the context with the RITM.
I didn't try the cart approach since I'm not familiar with it, and the above was a simple fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:27 PM
Hi Simon,
REQ workflow is triggering workflow for RITM. and the approvals in REQ, are gated approvals for RITM. So if REQ is not getting triggered, RITM will never get triggered.
You can remove gated approvals from REQ workflow and then it will not create any approvals for Req.
Thanks.
PS: Hit like, Helpful, Correct, if it answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:33 PM
Yikes, I was afraid of that. Was hoping the flexibility of the platform would let me alter that behavior.
The reason I don't want to change the REQ workflow is because the approval steps there still need to be preserved for all other RITMs. This particular RITM in question is trivial and occurs quite often, so I wanted to see if I can bypass the REQ workflow all together.
Perhaps I need to think of another approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:30 PM
One question.
How are you creating the REQ? Are you doing it directly through GlideRecord?
If yes, that will not work, as you need to use the cart API to order that item from your inbound action.
Something like this
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f');
cart.setVariable(item, 'os', 'Linux Red Hat');
var rc = cart.placeOrder();
gs.addInfoMessage(rc.number);
Once you generate it, you will get the REQ number from rc.number and you can glide on the sysapproval table to control the approvals on REQ and RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:36 PM
Thanks for the reply. Yes I am creating via GlideRecord. Can you elaborate on what you mean by that it won't work? As I mentioned, the records are getting created as expected and I was able to set the REQ Approval state as expected. I'm wondering if there's a way to trigger the RITM workflow without a workflow on its parent REQ.