need to update the data from service portal to incident

Sandeep74
Tera Expert

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;



}
}
})();

 

Sandeep74_0-1668580224521.png

 

 

 

 

 

3 REPLIES 3

Sebastian L
Mega Sage

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

hello Sebastian,

 

now  the update function is not working at all as  I have made all the functions correctly in that 

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