- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 04:14 PM
Is there an easy way to check if a reference field has no options available to select, and so make it so the field is no longer mandatory?
I would like to have a check on the service portal so after the building is changed it checks to see if the floor has any options, and if not then it changes the fields mandatory to false.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:02 PM - edited 12-06-2022 06:02 PM
Try this on onLoad client script
var f1 = g_form.getControl("FieldName");
if(f1.options.length != 1 ){ //check if the dropdown has choices
g_form.setMandatory("FieldName",false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 04:35 PM
Hi @Travis Michigan ,
You need to run your script on load and need to check the records in the reference table by using filter if there is any if you got any record then you can mark as mandatory if not then don't.
I hope this helps
Please mark my answer correct if this helps you
Thanks
Mohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:02 PM - edited 12-06-2022 06:02 PM
Try this on onLoad client script
var f1 = g_form.getControl("FieldName");
if(f1.options.length != 1 ){ //check if the dropdown has choices
g_form.setMandatory("FieldName",false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 04:15 AM
To get it to do precisely what I wanted I ended up using it as an onChange but that worked. Thank you so much @Edgar10 !