- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 12:36 PM
Hi all,
I've created a widget that presents a button on a record producer in Service Portal. When this button is pressed a modal window opens that presents variables and display values from some of the fields on the form.
Before opening the modal, if there are any mandatory fields not filled in, I want an alert to open first to say there are mandatory fields to fill in (much like OOTB Submit button will do).
Here's the script that opens the modal, and collects values to pass to the HTML. I've tried g_form.hasMissingFields(), but I keep getting an error that this is not function. Any ideas? thanks!
c.openModal = function() {
var arr = g_form.getMissingFields();
alert("The ID s of fields that are mandatory are not filled : " + arr);//this is part that's not working
$scope.data.reqName = g_form.getDisplayValue('u_requester_name');
$scope.data.dep = g_form.getDisplayValue('u_department');
$scope.data.phone = g_form.getDisplayValue('u_phone_number');
$scope.data.hpc = g_form.getDisplayValue('u_hpc');
$scope.data.date = g_form.getDisplayValue('u_date_of_notary');
$scope.data.delDoc = g_form.getDisplayValue('u_delivery_of_documents')
c.modalInstance = $uibModal.open({
templateUrl: 'notary-print.html',
scope: $scope
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 02:10 PM
Hi,
This link may assist you: https://www.servicenowguru.com/system-ui/ui-macros/mandatory-fields-service-catalog-checkout/
Otherwise, one way to do this would be to to have your UI action button check through the fields to see if anything is missing, much like:
if (g_form.getValue('fieldname') == '' || g_form.getValue('fieldname') == '') {
alert("Please fill in the mandatory fields first before continuing");
}
...something like that.
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 06:15 PM
Understood. Let me know if you need anything else!
🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!