- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 05:27 PM
Hello,
I know that what I've written is a bunch of nonsense, but I am horrible at scripting and I would really like some help.
My goal is , once I type in a User (subject_person) to auto-populate my form field (appraisal_due_date) with the information that is on the HR Profile (u_appraisal_due_date).
Pertinent Information:
Name of my Script Include: getUserHRProfileInformation
Name of HR Profile: sn_hr_core_profile
Name field on HR Profile: user
Here is the Nonsense the I have:
_____________________________________________________________________
Script Include:
Solved! Go to Solution.
- Labels:
-
Human Resources Service Delivery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 06:08 AM
@Hola Ola Please try the following version.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var abc = g_form.getValue('subject_person');
var ga = new GlideAjax('sn_hr_core.getUserHRProfileInformation');
ga.addParam('sysparm_name', 'getUserHRProfileInformation');
ga.addParam('sysparm_user', abc);
ga.getXMLAnswer(getResponse);
function getResponse(response) {
g_form.setValue('appraisal_due_date', response);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 07:04 PM
Here is the updated script include. Make sure to create this script include in Human Resource: Core application scope. Otherwise it will not work.
var getUserHRProfileInformation = Class.create();
getUserHRProfileInformation.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserHRProfileInformation: function() {
var user = this.parameter('sysparm_user');
var gr = new GlideRecord('sn_hr_core_profile');
gr.addQuery('user', user);
gr.query();
if (gr.next()) {
return gr.getValue('u_appraisal_due_date');
}
},
type: 'getUserHRProfileInformation'
});
Here is the onChange client script for the user field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var abc = g_form.getValue('subject_person');
var ga = new GlideAjax('global.getUserHRProfileInformation');
ga.addParam('sysparm_name', 'getUserHRProfileInformation');
ga.addParam('sysparm_user, abc);
ga getXMLAnswer(getResponse)
function getResponse(response) {
g_form.setValue('appraisal_due_date',response);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 11:39 AM
Hello @Sandeep Rajput,
Thank you very much for your help, really appreciated.
Having followed your scripts and recommendations, it did work. I do however believe it is something that I may have missed.
Here's is a screenshot of the Script Include as I currently have it:
___________________________________________________________
Here's is a screenshot of the Client Script as I currently have it:
____________________________________________________________________
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 02:01 PM
@Hola Ola Sorry, I am confused here. Did the changes suggested by me work for you or not? Also, you shared screenshot of Script include twice. Could you please share the screenshot of client script too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 05:24 AM
Good morning @Sandeep Rajput ,
My sincerest of apologies for the confusion. I didn't realize that I sent the Script Include twice.
Here is the Screenshot of the Client Script:
To answer your other question, No, it hasn't worked. But I'm sure it must me something I haven't done right.
I do appreciate your efforts though.
Thanks