Add a custom submit button in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 02:09 AM
Hi experts,
We are trying to add a custom button, based on the OOTB submit button.
we've created a clone of the OOTB "Form" widget.
the required functionality: create a submit for approval button which will create a new record with a different status. we tried to track to Submit button funtionality and just update the status, but with no success.
here is what we got so far:
HTML:
<button ng-if="getPrimaryAction()" type="submit" ng-click="SubmitForApproval()" ng-disabled="submitting" class="btn btn-primary action-btn pull-right" gsft_id="{{::getPrimaryAction().sys_id ? getPrimaryAction().sys_id : ''}}">Submit for Approval </button>
<button ng-if="getPrimaryAction()" type="submit" ng-click="triggerUIAction(getPrimaryAction())" ng-disabled="submitting" class="btn btn-primary action-btn pull-right" gsft_id="{{::getPrimaryAction().sys_id ? getPrimaryAction().sys_id : ''}}">${Submit} </button>
Client script:
$scope.getPrimaryAction = function() {
var primaryActions = $scope.data.f._ui_actions.filter(function(action) {
return action.primary;
});
return (primaryActions.length) ? primaryActions[0] : null;
}
//Start Test
$scope.getSubmitForApprovalAction = function() {
return '{"sys_id":"70910f0787a19210a52f11fc3fbb3555","form_style":"unstyled","is_link":false,"action_name":"submitForApproval","name":"WP Funded Service - Submit for approval","is_button":true,"is_context":false,"primary":true}';
}
$scope.SubmitForApproval = function() {
//Perform additional actions if needed
// $scope.data.offering_status = "pending_approval";
// $scope.page.g_form.setValue("offering_status","pending_approval");
alert(g_form.getValue("offering_status"));
/* // Call the function to submit the form data to the server
$http.post('/api/now/table/x_g_dnl5_workpath_wp_offering', $scope.data)
.then(function(response) {
spUtil.addInfoMessage("Form submitted for approval successfully.");
}, function(error) {
spUtil.addErrorMessage("Failed to submit for approval.");
});*/
};
Any suggestions?
Thanks,
Tomer