regarding Payload builder and REST message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
This is regarding the action which has the below
Step 1 : Accept input via an Action.
Step 2: Use a Payload Builder to construct the payload.
Step 3: Make a POST REST API call to Ansible AWX along with payload from STEP 2 , which triggers a playbook execution and receive a response containing the AWX Job ID.
NOTE : this Step 3 can be slow because it needs to execute playbook approximately 3-4 minutes as we have bunch of Task.
The Service now needs to launch one more action to check the status of the AWX job id
Currently, we have a separate action to check the status of AWX job id is either success or failure we use service now loop “Do the following” to poll the AWX job status every 30 seconds until it completes (either success or failure), or until a flow variable reaches a defined threshold.
My question is: If I want to include this polling logic as Step 4 (i.e., immediately after the REST message is sent),
how can I achieve that within the same action or flow?
Should this polling remain as a separate action outside the main flow (as we have today), or is there a better way to integrate it directly after the REST call with a time delay?
Would appreciate your thoughts or suggestions on best practices for this kind of asynchronous job monitoring within ServiceNow flows.
i am looking at similar option like loop " do the following" inside action so that the REST API be made till it get the success or failure or max limit set
advantage of doing this , today our flow involved many steps which can span up to 100 steps in the flow
now combining the 3 steps in an action is the efficient way of doing and hence looking for option here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi,
I think your problem is only the size of your flow, the logic seems right. Try to divide your flow in subflows that can be reused.
As a suggestion, I would put the pulling and the action you mentioned inside a subflow.
If it's useful, please mark it as useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
You can include the polling logic within the same action/flow in Flow Designer by using a Wait for a duration / Wait for condition step right after your REST message call, then looping with a condition check until the job ID returns success/failure or a max threshold is reached; however, keep in mind that long running loops and frequent polling inside a single flow can impact performance and maintainability, so many implement the polling as a separate action/sub flow triggered off the initial REST call to keep the main flow simpler and easier to manage (which also aligns with the design guidance around keeping flows efficient and avoiding long blocking loops).....
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
@kaushal_snow thanks for your suggestion , i will give this a thought and also try this solution
As you mentioned having a polling logic is technically possible but not recommended , i might have this logic outside the action.
thanks @Ricardo26 for sub flow idea for polling and getting the AWS status
will try this and accept both of your suggestion as "Accept as solution" once tested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
@kaushal_snow
please find the attached screenshot , here is what i have achieved so far
ignore script in STEP 1
STEP 2: generated the payload using payload builder
STEP 3: make the REST API POST call with the payload generated in STEP 2
STEP 4: used the response body from the STEP 3 to parse the data to get the AWX job id
STEP 5 : have to wait for certain time duration and check for the AWX job status
Question : what should be the record and table ? and the conditions ?
AWX job status can be pending , running , success or failure
wait for condition should be in loop either it is success or failure or timeout or flow variable after 100 try or something
STEP 6: how to add the if logic , if job status is successful
STEP 7 : REST API get call to get the data from the playbook ,
STEP 8 : parse the data received from STEP 7
OUTPUT the parsed data as data pill
