Get the Mandatory field 'column names' from Incident form (Default view)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 06:38 AM
Hi All,
I have a Custom table, where I have fields similar to 'Incident' table like short_description, description, priority etc.. if the fields are mandatory on Incident form in anyways (like Client script, BR etc..), I want to make the fields mandatory in Custom table. From dictionary I can fetch but from other means not sure how ..Could you please let me know how it can be achieved..
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 06:58 AM
Hi,
Check your instance(client script, ui policy).
It is very easy process you can apply make mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 06:53 AM
Hi,
You can try using Display BR where you glide into dictionary table to see mandatory fields and store those mandatory field details in g_scratchpad object and accees the same in client script and make field mandatory accordingly.
However, if you have any fields which are made mandatory by UI policy or client script on incident table then it would be difficult to make the same in your custom table.
These dictionary changes are modified rarely on incident table so I would rather suggest you could just try making them mandatory at dictionary level on your custom table.
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2022 07:00 AM
Hello,
There is one method of g_form which helps in identifing the field is mandatory or not .
g_form.isMandatory(String fieldName)
Returns true if the field is mandatory.
For all the fields on the form you have to write an onload client script
1. first you need to fetch all fields on the form and check field is mandatory or not like below,
function onLoad() {
var fields = [];
for (var i = 0; i < g_form.elements.length; i++) {
if(g_form.isMandatory(g_form.elements[i].fieldName))
fields.push(g_form.elements[i].fieldName));
}
alert("Mandatory Fields are : "+fields);
}
Please mark my answer as correct if it helps you.
Thanks,
Shahebaz
