Flow on cat item is not triggering when created via a scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 08:44 PM - edited 06-27-2024 08:44 PM
Hello,
I have a catalog item that uses a flow. When I submit the catalog item manually the flow behaves as expected. I eventually want to be able to schedule a job that runs that uses this catalog item/flow. My question is regarding the scheduled job. I am using a PDI Instance on Washington.
I am using the below script to test the scheduled job and it is creating the REQ and the RITM fine but does not kick off the flow that is assigned as the process engine for this catalog item. I would expect the flow to update the State, Stage, Assignment group, Short Description and trigger a SCTASK. What do I need to amend in the script so the flow will also trigger. The trigger condition on the flow is currently set to "User who initiates session". I have tried swapping it to "System User" but that didn't seem to make any difference. I am not a coder so please be kind (dumb it down) with your explanation 🙂
Also, the Stages don't appear to be correct when the scheduled job runs. I am assuming this is because the flow is not running that has the Stages defined. If I am on the wrong track about that I would appreciate someone letting me know. The bottom one is manually run and is correct. The top one is from the scheduled job.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 09:28 PM
Hi there,
Have to reproduce. Though first thing I immediately notice, is that you are "manually" creating the request, requested item and I don't see any variables?
Have you considered using the CartJS instead? Way easier and more reliable.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 09:41 PM
Hi @riskay123
Let give the CartJS a try.
var cart = new sn_sc.CartJS();
var request =
{
'sysparm_id': '42151881475eb910ab9bb6bf016d4308', //catalog item sys_id
'sysparm_quantity': '1', //quantity
//variables
'variables':{
'requested_for': '6816f79cc0a8016401c5a33be04be441',
}
};
var cartDetails = cart.orderNow(request);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 09:49 PM
Or you can also consider to add this line to your script.
sn_flow_trigger.FlowTriggerAPI.fireCatalogTrigger('<flow_internal_name>', ritm);
Ref:
Business Rule: Start FlowDesigner Flow
URL: https://<instance_name>.service-now.com/sys_script.do?sys_id=837a49f63ba013008ed00d8044efc4e5
Cheers,
Tai Vu