How can I use ServiceNow's FlowAPI to restart a subflow?

Dan108
Tera Contributor

 

Here is a scenario we are trying to solve for:
1. User submits a request for software installation approval using one of the TSS Now record producers available in the Service Catalog.
2. Upon submittal, the record producer creates a record in the TRM Product Request table. It also populates dozens of Catalog Variables associated with that record producer. Most of these variables are not visible to the user; instead they are populated behind the scenes via scripts and used in the sub flows that will handle this request.
3. Once that TRM Product Request record is created, the Flow Designer flow called "TSS Product Flow" is triggered. This flow inspects a single variable called "TSS Product Request Trigger". Depending on the value of this variable, TSS Product Flow calls the appropriate sub flow to continue with the flow to handle this request from the user.
4. After the sub flow is fired by the TSS Product Flow, the sub flow looks at the information in the request and passes the request along to the appropriate people/groups to review and approve/reject the request.
5. During this process of assigning tasks/approvals to request reviewers, additional sub flows are fired. e.g. when the request gets to the point of needing review from a Technology Manager then a sub flow called "TSS Flow x.x Technology Manager Approval" is fired.... and then when it gets to the point of being reviewed by CSO, ALM and Legal then a sub flow called "TSS Flow x.x Stakeholder Review" is fired).
6. PROBLEM IS that sometimes there will be a request that ends up 'stalling' in the flow (i.e. an Ask for Approval step is skipped b/c no one was in the assignment group, or the flow encounters an error during a Lookup Record step).... when this occurs, we want to correct the issue that caused the request to get 'stuck' and then restart the sub flow.

 

FlowAPI
1. We have tried experimenting with this ServiceNow-provided API but are running into some issues
2. We have created a test script using FlowAPI's '.restartFlowFromContext' method that allows us to restart the "TSS Product Flow" for TRM Product Requests that are LESS THAN 7 days old
3. When we try to run that API's 'restartFlowFromContext' method on TRM Product Requests that are MORE THAN 7 days old, then we get an error message in our App Logs that says "The sysevent record for the supplied context is no longer present on the system."
4. We discovered that that the table "sys_flush_cache" has a record in it that is associated with the 'sysevent' table, which is configured to wipe/delete 'sysevent' records older than 7 days
5. PROBLEM IS that TRM Product Requests can take multiple weeks before all stakeholders have reviewed and approved, so its often the case that the request is older than 7 days when it gets stuck in flow

 

Our Question:
1. How can we restart a sub flow for a request older than 7 days in order to prevent a user from having to submit it again?
2. Is there a way to preserve the life of the 'sysevent' record so that we can restart sub flows after a request is 7 days old?
3. Given the scenario above, is there another way in which we can use the FlowAPI to restart an action/sub flow that would resolve our business need?

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

regarding the table sysevent: It's a so-called rotated table and represents the backbone of ServiceNow. Changing any configurations here without deep knowledge can have large impacts and crash your system in the worst case.

I'm irritated about the error message itself, as in that table you only can find the trigger to start a (sub-)flow but all the information about a running (sub-)flow are stored in other tables. Therefore I cannot understand the relation to the sysevent table. Also in the API I cannot find any hint.

I recommend creating a support ticket and ask ServiceNow your question again.

Maik

Mary Beth Hutch
Tera Guru

Were you ever able to resolve this issue?