- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 11:04 PM
I am using REST Api - async step where I am getting a payload with these details for change request form -
1. Short Description
2. Description
3. Requester
4. Configuration Item
5. Correlation ID
I have made all these mandatory in the body
Now I see if the body is recieved empty the change is still created and flow is completed and flow execution id is sent as a response.
Ideally , I think it should flow should run into error.
Secondly If the CI which is recieved is not found in ServiceNow or is retired we need to abort the action and send an error message back but I see in this case flow goes into error but still the flow execution id is sent as a response.
Basically how do I send an error response for above cases?
Solved! Go to Solution.
- Labels:
-
Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 11:09 PM
Hello,
Can you try this method
current.setAbortAction(true);
this will abort the current action
Please accept the solution of it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 10:22 PM
I am using REST Api - async step where I am getting a payload with these details for change request form -
1. Short Description
2. Description
3. Requester
4. Configuration Item
5. Correlation ID
I have made all these mandatory in the body
Now I see if the body is recieved empty the change is still created and flow is completed and flow execution id is sent as a response.
Ideally , I think it should flow should run into error.
Secondly If the CI which is recieved is not found in ServiceNow or is retired we need to abort the action and send an error message back but I see in this case flow goes into error but still the flow execution id is sent as a response.
Basically how do I send an error response for above cases?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 11:12 PM
Hi
In Servicenow, we have two terms called "Return false" and "current.setAbortAction(true);" which is used to abort a action which gets used but you will have understand the their feature first so, here it is
Return false does just that, - it returns false. It doesn't prevent additional business rules from running.
current.setAbortAction(true); stops the business rule and stops the system from continuing to run additional (higher order) business rules.
Now, how do you use it in a Business Rule ? see below an example :
if(current.sysapproval.u_group_sla=='6')
{
var now = new GlideDateTime();// current date time
gs.addInfoMessage('current updated date..'+now);
var duedate= new GlideDateTime(current.sysapproval.due_date);
gs.addInfoMessage('.due date is ....'+duedate);
if(now.getDate() > duedate.getDate()){
gs.addErrorMessage('please select the future dates');
current.setAbortAction(true);
}
else
{
current.state='approved';
current.update();
new ApprovalUserFeedback().approved(current);
}
}
else{
current.state='approved';
current.update();
new ApprovalUserFeedback().approved(current);
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2022 10:13 PM
Hi
Glad to see my answer helped you, Kindly mark the answer as Correct & Helpful both such that others can get help.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 11:16 PM
Hi,
You can use
current.setAbortAction(true)
this will abort the current action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2022 09:49 PM
We can abort the action using current.SetAbortAction(True) but we do not have an option to send a custom response in flow designer. It always sends the execution id by default.
