Pass the JSON payload as inputs to a flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 01:53 AM
Hello all,
I have created a scripted REST API, and in it, I have written a code like this,
var reqbody = request.body.dataString();
var parsedData = JSON.parse(reqbody);
try{
var inputs = {
"start_date" : parsedData.start_date.toString(),
"end_date" : parsedData.end_date.toString(),
"short_description" : parsedData.short_description.toString()
};
}
So, here now, I need to create these below steps:
1. I need a create a flow using flow designer, where I need to create a change request from the inputs of the above scripted REST API, Hence, I need to call the flow from the Scripted REST API itself and pass the inputs to create the CR.
2. After a CR has been created, then I need to validate change conflicts where the conflicts are currently returning from a script include,
If the script include returns like conflict detected, then I need to return the conflict type to the customer.
3 rd point I will try once I got to know how to achieve the above two points.
So, can someone please help me step by step how to do this?
Thanks a lot
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:45 AM
Hello ANkur,
Yes, now I am able to create a change request from Scripted REST API, but please guide me from here to achieve my goal.
Next to be checked is,
If the created CR has any conflict detected, then there is a conflict_status field available on change request and it shows, Conflict. So, here I also want to show the customer the response like, Change has been created with CHG0012345 but there is a conflict detected,
and then I need to check the Upcoming schedule entry which cannot create conflict again and show that to the customer.
Can you guide me here?
For your reference, I am pasting my Scripted REST API code:
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 09:51 AM
I already told how to do that above.
see this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 11:02 AM - edited 05-26-2025 11:38 AM
Yes Ankur,
You told me that, Thanks a lot for that But I am trying to get in detail to understand better.
like,
1, create a custom action and call it in the sub flow (here I am trying to find what logic can be written and what out puts should I get)
2. Secondly, if I glide record the table "Shedule entry" to find out next scheduling start date and update the aready created record to see if there will be no conflict, then I need to return the response to the customer.
But unfortunately, I am not aware of how to do this.
Thanks and Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 08:12 PM
that custom flow action will have script step
which script to use refer the OOTB UI action for Check Conflicts and then take it from there.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 12:29 AM - edited 05-27-2025 12:41 AM
Hello Ankur,
In line number 6, I am getting the created Change request sys_id
but in line number 17, I am getting the Row count as 0.
When I write the same script in scripts background, by hard coding the sys_id, then it is giving the right value.
Actually in the line number 13, I have updated like this,
Where it went wrong here?
Regards,
Lucky