How to create a Save button in Service portal view page in service now

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018 06:12 AM
I need to create a Save button in Service portal view page in service now from where user needs to update the details and then submit it for action.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2019 11:56 AM
i have used above script.but it is not working
i have added information in all form fields and clicked on Save button . but it is not Saving form
<input type="text" ng-model="c.data.name">
<button type="button" class="btn btn-default" ng-click="c.Save()" >save</button>
c.Save=function(){
c.server.get({
action:'update',
name :c.data.name // example
//define the values which you want to save in key-value pair to the
}).then(function(r){
});
(function() {
// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");
// Valid GlideRecord
gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
// Valid sys_id
if (!gr.get(data.sys_id))
return;
//Button Visibility
if (data.table == 'u_my_shuttle_requesting' && gr.u_state=='Update Needed' && gr.u_requestor_name == gs.getUserID()) {
data.showButton=true;
}else{
data.showButton=false;
}
if (input && input.action) {
var action = input.action;
// If table
if (data.table == 'u_my_shuttle_requesting') {
if (action == 'update') {
gr.setValue('u_name',input.name);
gr.update();
data.fltr='/shuttle_request/?id=shuttle_request';
}
}
}
})();
form Not Saved. CAn you please provide your help .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 01:28 AM
Hi Karishma,
I know this works fine, but is there any other way to get all the changed values automatically? I want to avoid using gr.setvalue() for each input.
Regards,
Saad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2021 01:17 AM
I have tested it but unfortunately it did not work and my questions are:
1. On Server Script
Table name is test_training
test_remark is a column of test_training table so below was the udpate but no lucky
if(input.action=='update'){
var gr=new GlideRecord('test_training');
gr.get('test_remark');
gr.setValue('test_remark',input.name);
gr.update();
}
2. HTML
<div>
<input type="text" ng-model="c.data.name">
<button type="button" class="btn btn-default" ng-click="c.Save()" >save</button>
</div>
How can we add the test_remark is automatically filled without the text box, so it is correct that this line <input type="text" ng-model="c.data.name"> can be removed and put it the value on the server script or client script for test_remark = 'Testing'.
Please advise.
Thank you