- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:48 AM
Hi all,
I've got a record producer I'm fixing to work in Service Portal. The form has a number of mandatory fields. I've built a widget to put a "Save as Draft" button on the form. When the user clicks the button, they are prompted with an alert. When they click "OK", I need any mandatory fields on the form to change to "mandatory = false", and then for the form to submit as normal, creating a new ticket on the target table with a custom "u_status" field set to "u_draft". Any help would be great, thanks!
Here's my client script in my widget:
function($scope, $rootScope, $timeout){
var c = this;
var g_form = $scope.page.g_form;
var arr = g_form.getFieldNames();
//need something here to get "arr" down to only fields that are mandatory...how to do this?
c.saveDraft = function(){
alert('Are you sure you want to save as Draft?');
$scope.page.g_form.setMandatory(arr,false);//needs to set the fields that mandatory on the form to not mandatory
g_form.setValue('u_status','u_draft');
alert('should save now');
$timeout(function() {
//$scope.page.g_form.checkMandatory = false;
$("[name='submit']").trigger('click');
});
return true;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:58 AM
I figured it out. Here's my script:
function($scope, $rootScope, $timeout){
var c = this;
var g_form = $scope.page.g_form;
var arr = g_form.getFieldNames();
c.saveDraft = function(){
alert("Are you sure you want to save the form?");
for (var i in arr) {
var field = arr[i];
$scope.page.g_form.setMandatory(field,false);
}
g_form.setValue('u_status','u_draft');
$timeout(function() {
$("[name='submit']").trigger('click');
});
return true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:58 AM
I figured it out. Here's my script:
function($scope, $rootScope, $timeout){
var c = this;
var g_form = $scope.page.g_form;
var arr = g_form.getFieldNames();
c.saveDraft = function(){
alert("Are you sure you want to save the form?");
for (var i in arr) {
var field = arr[i];
$scope.page.g_form.setMandatory(field,false);
}
g_form.setValue('u_status','u_draft');
$timeout(function() {
$("[name='submit']").trigger('click');
});
return true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2019 08:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2019 08:32 AM
Hi Patrick can you please share your whole widget. I am having the same requirement and i dont have any clue about angular js . Please help me