Skip to content

Commit b43f992

Browse files
authored
Create onChangeClientScript.js
1 parent 7f50ab1 commit b43f992

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* In order for this to work make sure to have an onChange catalog client script on a variable that is type Requested For. This variable
3+
* already autopopulates the logged in user with its OOB functionality. In the updateUserFields function you can add any other user fields
4+
* that you might need.
5+
*/
6+
7+
function onChange(control, oldValue, newValue, isLoading) {
8+
//This variable will store the sys_id of the user that populates in your requested for variable
9+
var userID = newValue;
10+
11+
var ga = new GlideAjax(ReferenceQualifierAjaxHelper);
12+
ga.addParam('sysparm_name', 'getUserInformation');
13+
ga.addParam('sysparm_user', userID);
14+
ga.getXMLAnswer(updateUserFields);
15+
16+
function updateUserFields(response) {
17+
var returnedData = JSON.parse(response);
18+
g_form.setValue("email", returnedData.email);
19+
g_form.setValue("location", returnedData.location);
20+
g_form.setValue("title", returnedData.title);
21+
g_form.setValue("phone", returnedData.phone);
22+
}
23+
}

0 commit comments

Comments
 (0)