need to update the data from service portal to incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:30 PM
I need to update the data from service portal to incident table fields and I have created the server side side and client side but the details not passing on that how we can update the data to those fields and how we can get the data through that fields from incident .
here is the server side code and client side code help me with this any changes needed do let m eknow:
client side:
function($scope){
var c = this;
$scope.userUpdate=function(user){
$scope.data.email=user.email;
alert(user.email);
$scope.data.caller=user.caller_id;
alert(user.caller_id);
$scope.data.shortdescription=user.short_description;
alert(user.shortdescription);
$scope.data.description=user.description;
alert(user.description);
$scope.data.State=user.state;
alert(user.state);
$scope.server.update();
location.reload();
}
}
server side code:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.array=[];
var gr=new GlideRecord('incident');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
if(gr.next()){
data.array.push({
caller:gr.caller_id.toString(),
email:gr.email.toString(),
shortdescription:gr.short_description.toString(),
description:gr.description.toString(),
State:gr.state.toString()
});
}
if(input){
var gd=new GlideRecord('incident');
gd.addQuery('assigned_to',gs.getUserID());
gd.query();
if(gd.next()){
gd.caller_id=caller;
gd.short_description=shortdescription;
gd.description=description;
gd.state=state;
}
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:12 PM - edited 11-15-2022 11:13 PM
Hello,
Something in the line of this. Don't just copy the code, but try to understand where it updates the server and then what to look for. When you are on the server and you need input from the client you write input as the variable:
//Client
$scope.userUpdate= function () {
$scope.data.email=user.email;
$scope.data.caller=user.caller_id;
$scope.data.shortdescription=user.short_description;
$scope.data.description=user.description;
$scope.data.State=user.state;
$scope.data.op = 'updateUser';
$scope.server.update($scope).then(function(response) {
$scope.data.op = null;
});
};
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.array=[];
var gr=new GlideRecord('incident');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
if(gr.next()){
data.array.push({
caller:gr.caller_id.toString(),
email:gr.email.toString(),
shortdescription:gr.short_description.toString(),
description:gr.description.toString(),
State:gr.state.toString()
});
}
if(input && input.op='updateUser'){
var gd=new GlideRecord('incident');
gd.addQuery('assigned_to',gs.getUserID());
gd.query();
if(gd.next()){
gd.caller_id=input.caller;
gd.short_description=input.shortdescription;
gd.description=input.description;
gd.state=input.state;
gd.update();
}
}
})();
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:43 PM
hello Sebastian,
now the update function is not working at all as I have made all the functions correctly in that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 04:05 AM
The key is how to update from client to server:
$scope.server.update($scope).then(function(response) {
$scope.data.op = null;
});
Let me know how it is looking currently. Best thing is to log out on both client and server side, so we know how far you are. Add console.log statements so you can follow the interaction between client and server!
Best regards,
Sebastian Laursen