Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update Work notes with script Include

maryam7
Tera Expert

Hi All, 

I want to get the Location field and copy in work notes on incident form . I know I can write with BR. but I would like to write with Script include. I wrote the this script include and BR. but it does not work. can you help me please . 

Script Include:

*************************************************

var UpdateWorkNotes = Class.create();
UpdateWorkNotes.prototype = {
initialize: function() {
},
location: function(usr){
var Gruser = new GlideRecord ('sys_user');
Gruser.addQuery('sys_id',usr);
Gruser.query();
if (Gruser.next()){
var location = Gruser.location.name.toString();
gs.log("user location" + location, "test");
return location;
}
},
type: 'UpdateWorkNotes'
};

********************************************************

BR: before insert or update 

var x = new UpdateWorkNotes(); //call script include
var location = x.location(current.caller_id.toString()); // set location
current.setValue('work_notes', location);

})(current, previous);

1 ACCEPTED SOLUTION

You can simplify things instead of using a script include just use:

current.work_notes = current.location.getDisplayValue();

View solution in original post

5 REPLIES 5

You can simplify things instead of using a script include just use:

current.work_notes = current.location.getDisplayValue();