Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Stop updating State field when I click on Draft button at Portal.

Supriya25
Tera Guru

Hi,

We have two buttons on Records
Ui Actions : Draft (v_draft) this button does not apper at portal ,
Portal : "Save Draft"

Desktop side we have one 

OnSubmit Client script OnSubmit Client script 
if(g_form.getActionName()!='v_draft') 
{
g_form.setValue('state','Progress') ; 
return true; 
}else{ 
return false; 
}
Ui Action : Draft(v_draft)
Client =true
form=true
function unmadate(){
g_form.setMandatory('customer' false);
gsftSubmit(null,g_form.getFormElement(),'v_draft');
}
if(typeof window=='undefined'){
saverecord();

function saverecord(){
current.update();
action.setRedirectURL(current);
}


 Portal side : When we click on 'Save Draft" button record has to save record , but should not change state value. but here State value change to "Progress". this ObSubmit triggering . how to stop controlling it.

HTML :
<button id="save_draft" ng-click="validateAndSubmit()" class="btn btn-primary"> Save Draft </button>

Client Controller :
$scope.getPrimaryAction=function()
{ 
var primaryActions=$scope.data.f._ui_actions.filter(function(Action)
{
 if($sco[pe.data.table!='account_benefit'){
 if($scope.data.table!=6) return''; 
else
 return action.primary 
});
 return (primaryActions.length)? primaryActions[0]:null; 
}


 $scope.validateAndSubmit = function() 
{
 var primaryAction = $scope.getPrimaryAction(); 
if(primaryAction)
{
 $scope.triggerUIAction(primaryAction) 
}


 $scope.triggerUIAction=function(action)
{
 $scope.$evalAsync(function (){ 
if(g_form)
{ 
$scope.submittiing=true; 
if(!g_form.submit(action.action_name||action.sys_id)){
$scope.submitting=false;
}
}


var primaryAction = $scope.getPrimaryAction();  returning OOB UI action "Update" button details in object format
[{}] - SysID, name, primary



Please help me how to stop updating State field with "Progress". this ObSubmit triggering . how to control it.



0 REPLIES 0