
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2020 08:22 PM
Hello All,
Hope all are doing great.
For catalog item in platform view, we can use g_form.getMissingFields() to get mandatory fields which are empty. But I want same functionality in portal, unfortunately above method is does not work in portal. Is there any other way to achieve same?
My use case: I have a button in portal and when I click that button, It should do next task only when there are no mandatory fields on the form which are empty.
Also When we try to redirect user to any other URL in catalog form (When user has already filled the form but did not submit), it will popup a alert for confirming to leave current page and data will be lost. How can we avoid the popup. the data will be auto-saved in my use case before redirecting user to another URL. Hence I do not want to show the alert.
Thanks
Ali
Thank you,
Ali
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 05:38 AM
A quick example of a way to check for empty mandatory fields
function filterForMissingMandatoryFields(field){
//check if field is mandatory
if($scope.page.g_form.isMandatory(field)){
//return if there is no value
return !$scope.page.g_form.getValue(field);
}
}
$scope.getMissingFields = function(){
//get all fields
var fieldList = $scope.page.g_form.getFieldNames();
//return only mandatory fields that have no value
return fieldList.filter(filterForMissingMandatoryFields)
}
//Then call this function when you want to check
//$scope.getMissingFields() //this returns an array of empty mandatory fields
//of if calling from an ngClick just do this on the clickable element
// ng-click="getMissingFields()"
If the return is empty after calling it, it means all mandatory fields are populated.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 05:38 AM
A quick example of a way to check for empty mandatory fields
function filterForMissingMandatoryFields(field){
//check if field is mandatory
if($scope.page.g_form.isMandatory(field)){
//return if there is no value
return !$scope.page.g_form.getValue(field);
}
}
$scope.getMissingFields = function(){
//get all fields
var fieldList = $scope.page.g_form.getFieldNames();
//return only mandatory fields that have no value
return fieldList.filter(filterForMissingMandatoryFields)
}
//Then call this function when you want to check
//$scope.getMissingFields() //this returns an array of empty mandatory fields
//of if calling from an ngClick just do this on the clickable element
// ng-click="getMissingFields()"
If the return is empty after calling it, it means all mandatory fields are populated.
Hope this helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 04:45 AM
Thanks Chris
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2021 12:44 PM
Does anyone know if there is also an equivalent for AgentWorkspace (specifically a UI action). g_form.save() works, but getMissingFields does not.
In my use case, we're launching a modal window to collect more data before proposing a major INC but only want it to complete if all mandatory fields are complete on the form. The save will validate, but we can't come up with a condition to stop it from proceeding to the modal code.