- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 01:21 PM
I have tried to search the documentation for an API that allows me to fetch information on the current UI Policy or for Data Policies and I can't find it. Is there such an API?
Particularly, I am interested in learning about mandatory fields for incidents. I understand that you can set fields as mandatory in the UI Policy and in Data Policies.
As such, I need a REST API that will allow me to query the current UI Policy and Data Policies to build a full picture of the list of mandatory fields.
I'm sure these REST APIs and/or GraphQL APIs must exist. Right?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 07:09 PM
I don't think any such API exists
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
01-13-2025 03:41 PM
Maybe I am misunderstanding, but I don't think you would need or even want a REST API to achieve this. There are a number of places you can look:
- On the UI Policy Actions table (this is where UI Policies can set mandatory values with a low-code approach)
- In the Execute if true/Execute if false script fields on the UI Policy records
- In the Data Policy Rules (the low-code config for Data Policies)
- In the script section of client scripts
I would start by looking on the UI Policy Actions and Data Policy Rules tables and also doing a search for setMandatory in Studio Code Search.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 04:14 PM
I am automating the creation of incidents on behalf of a user via an OAuth generated access token. Literally the only method I have of interacting with ServiceNow is via an API. If I can't do it via an API, then I can't do it, period.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 06:26 PM
hi @lexicalunit
You can use the Table API to query the following tables:
sys_ui_policy: UI Policy records
sys_data_policy: Data Policy records
sys_ui_policy_action: UI Policy Actions (defines actions like making a field mandatory)
sys_data_policy_rule: Data Policy Rules (defines actions like making a field mandatory)
- Limitations:
This will only give you the raw data of the policies and their actions.
You'll need to parse the conditions (which can be scripted) yourself to understand when a field becomes mandatory. This can be quite complex and error-prone.
Parse these tables' data and extract the fields that are mandatory.
Example (to get UI Policies related to the Incident table):
GET /api/now/table/sys_ui_policy?sysparm_query=table=incident
GET /api/now/table/sys_data_policy?sysparm_query=table=incident
GET /api/now/table/sys_ui_policy_action?sysparm_query=ui_policy.table=incident
GET /api/now/table/sys_data_policy_rule?sysparm_query=policy.table=incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 05:10 PM
hi @lexicalunit
I hope you are well.
A small request from my end, If you think my past opinion has some contribution to clear your concept or idea or problem that you faced earlier and resolved it after reviewing and applying it. Please kindly mark this your best answer (Accepted Solution) 🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community.
Now you can accept multiple solutions against your post.
Stay safe and well.Thanks