Skip to content

Commit 829c6e7

Browse files
authored
Merge pull request ServiceNowDevProgram#733 from at8807602/scriptinclude
Scriptinclude
2 parents b2cbd7f + ff5d07c commit 829c6e7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
2+
if (isLoading || newValue === '') {
3+
return;
4+
}
5+
var aj = new GlideAjax("GetCallerDetails"); // This is the name of script include, as per the name of your requirement.
6+
aj.addParam('sysparm_name',"demoTest"); // This is calling a defined function in script include.
7+
aj.addParam('sysparm_caller_id',g_form.getValue('caller_id')); // getting a caller_id
8+
aj.getXML(callback);
9+
function callback(response){ // creating a callback function to store the response getting from script include.
10+
var answer = response.responseXML.documentElement.getAttribute('answer');
11+
alert(answer); // This will alert the details.
12+
}
13+
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This script include will help to get the details of caller Id_name like (email, first_name, last_name user_name etc.) mentioned in incident form with the help of on change client script by iniating a Ajax call.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var GetCallerDetails = Class.create(); // This will create a new class.
2+
GetCallerDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
3+
demoTest:function(){
4+
var caller = this.getParameter('sysparm_caller_id'); // this will make the instance for caller id
5+
var user = new GlideRecord('sys_user');
6+
user.addQuery('sys_id',caller); // This will query the parameter, if exist
7+
user.query();
8+
if(user.next()){ // If user found
9+
return "Email Id: " + user.email + "\n" + "First Name " + user.first_name + "\n" + "Last Name: " + user.last_name + "\n" + "User Id: " + user.user_name;
10+
}
11+
},
12+
13+
type: 'GetCallerDetails'
14+
});

0 commit comments

Comments
 (0)