Having issue with mandatory fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 08:54 PM
I'm currently working on ServiceNow REST API to create Incidents. For that I need to get the fields that are mandatory, so that I can make them required.
I have already tried getting data from sys_dictionary table but the mandatory fields are shown "false" in "mandatory" attribute.
Can anyone help me out?
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 09:49 PM
Hello,
Yes so why will scripts rest API not work? It is just the same as normal table API you just need to define the fields which you want to update. And using the link I had shared above you can return an error response if mandatory fields are not passed in the API.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 09:11 PM
Hi @DineshD ,
Fields are mostly made mandatory using UI policy/Client script, and is at form level only. Fields made madatory by script, that you will not be able to get via API, sys_dictionary will help you with only those fields of the table that are made mandatory at the dictionary level which is not used very often.
But similar to sys_dictionary there are other two tables that stores information about fields made mandatory by UI policies/ Data policies, that also can give you fair idea. Below are the tables you can try:
Table Name : sys_ui_policy_action
Table name : sys_data_policy_rule
I Hope this helps.
Please mark this helpful if this helps and mark as correct if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 09:44 PM
Hi @kamlesh kjmar ,
I have tried getting values from both the tables you mentioned above but I am getting duplicate values for same fields(one have "ignore" and other have "true" for "mandatory" attribute) in sys_ui_policy_action table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 09:49 PM
Hi @DineshD ,
Yes, Mandatory is a choice field which has 3 options true/false/ignore. Please apply a filter and retreive only those, whose mandatory is true.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 09:23 PM
Hi, if the fields are not mandatory at dictionary level, they may be mandatory in UI policy, data policy, client script or in before insert\update BR's. Rather than trying to identify these requirements dynamically I think you would be better just providing a list of fields that need to be populated.
Also, I would not consider an external API directly creating or updating a record to be best practice for any environment and would recommend a scripted REST API\import table type solution to ensure that all fields are correctly populated and return a meaning full response if they are not.