How to Set Mandatory Fields in a Scripted REST API without data policies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 10:44 PM
Hello,
I wanted to know how to set mandatory fields through a scripted REST API without enforcing a data policy. I am creating a record in a table based on the request of the payload. I want to make some fields mandatory, only then it should accept the request, else it should throw an error.
Please let me know how to achieve this.
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 12:46 AM
Thank you for marking my response as helpful.
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
11-28-2024 02:49 AM
Hi @Ankur Bawiskar ,
I tried writing onbefore script but it didn't work in my case. And i have the same issue which Lavanfya explained earlier in this case.
I have written POST method and there I am loading the data to staging table and created a transform map. and in transform map onbefore script section I was doing this manadtory field validation. But still in my case the data is loaded in the incident table as well as staging table. Please guide here.
Thanks,
Diksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 11:12 PM
it would be nice if you share complete script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2023 11:25 PM
The thing is the script is little messed up since I was trying multiple things together! Since I am stuck on this particular part I shared only that part of the script!