How To Save Form Using GlideRecord Update Method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2022 01:39 PM
Hi SNOW team,
I've cloned the form widget and created a custom SAVE button that is intended to save the updates made to the form when a user clicks the button. I realize, a UI Action button could have been used too, but the custom button made has custom functions that run when clicked.
On the server-script page file, I have a GlideRecord that runs and contains the update method. However, no changes are being captured to the form when the Save button is clicked. When the button is clicked, the form disappears from the portal page instead.
I would really appreciate it, if anyone has any insight to get the form to update via a GlideRecord and keep the form visible when the custom Save button is clicked.
The form is viewable from Service Portal.
HTML
<button class="btn btn-primary" ng-click="saveUpdate();">Save</button>
Client Script
$scope.saveUpdate = function() {
$scope.server.get({
action: "saveDataUpdate"
}).then(function(response) {
c.data = response.data;
});
}
Server Script
if (input) {
//Add script here
if (input && input.action == "saveDataUpdate") {
var updateFrom = new GlideRecord('sc_req_item');
updateFrom.addQuery('sys_id', data.sys_idX);
updateFrom.query();
if(updateFrom.next()) {
updateFrom.update();
gs.addInfoMessage("Updated");
}
}
}
FYI: "data.sys_idX" is used to pull the sys_id of the current record showing on form from URL via portal
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2022 07:25 PM
Hi,
Please refer below article might be helpful to you
https://serviceportal.io/create-custom-action-buttons-service-portal/
Please mark my response as correct or helpful if applicable.
Regards,
Mahesh