- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2017 02:34 AM
Hi Guys
I have a form widget, in that we are going to be creating records from. I can get my form on page fine, using sys_id=-1.
It is quite a lengthy form so therefore they required a save as draft and submit button. Using a record producer is prob out of the question now as they want to save as draft and come back later to complete.
I cloned the form widget and looked at the html part and could get the submit button added
However, what i need is, if save is clicked, then remove the required field stamp and save the record as a draft. I have a draft state in my form. My coding experience is pretty low, especially on the portal side
Any Pointers or anyone do this before?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2017 06:41 AM
You could try this, Brendan.
HTML Button near the bottom of the form:
<button type="button" ng-click="saveAsDraft()" class="btn btn-primary action-btn pull-right">
Save as Draft
</button>
Method added to the Client Script (controller), just before the last brace.
$scope.saveAsDraft = function() {
for (var x in $scope.data.f._fields) {
g_form.setMandatory(x, false);
}
$scope.triggerUIAction($scope.getPrimaryAction());
}
The saveAsDraft function gets all of the fields on the form, sets them as not mandatory, then triggers the save.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 05:45 AM
Justin, you know your portal!
I wish i could mark that correct to. Thanks a million
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2018 06:12 PM
Some reason it's not working for me, I can see ng-click is getting fired but it's not setting mandatory for false nor it's saving the record.
I added the code to the end.
I can see below error on the console though.
TypeError: Cannot read property 'action_name' of null
any thoughts?
function appendError(error) {
$scope.errorMessages.push(error);
spUtil.addErrorMessage(error.msg + error.fileName);
}
$scope.saveAsDraft = function() {
for(var x in $scope.data.f._fields) {
g_form.setMandatory(x, false);
}
$scope.triggerUIAction($scope.getPrimaryAction());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2018 08:12 PM
Some reason it's not working for me, I can see ng-click is getting fired but it's not setting mandatory for false nor it's saving the record.
I added the code to the end.
I can see below error on the console though.
TypeError: Cannot read property 'action_name' of null
any thoughts?
function appendError(error) {
$scope.errorMessages.push(error);
spUtil.addErrorMessage(error.msg + error.fileName);
}
$scope.saveAsDraft = function() {
for(var x in $scope.data.f._fields) {
g_form.setMandatory(x, false);
}
$scope.triggerUIAction($scope.getPrimaryAction());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2019 10:51 AM
did you get Solution for this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 12:10 AM