Auto Populate New Hire's Department

rachelconstanti
Mega Sage

We have a new hire order guide with a variable of New Hire.

Need to auto populate the department of the user that is entered into that New Hire variable.

 

I am using this onChange client script:

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

// autoPopulate is our callback function
g_form.getReference('new_hire', autoPopulate);

}

function autoPopulate(et) {
//set values after getting reference
g_form.setValue('cmn_department', et.getValue('new_hire_dept'));
 

}
 
I've tried department in place of cmn_department but no luck.
I used the auto populate feature in Vancouver but that does not work if you are not a licensed 'itil' user (I'll go this route if anyone knows how to get around that issue.
 
I am using a similar client script to auto fill an employee type variable which works. 
 
What am I missing to get the department to autopopulate based on the hew hire?
 
Thank you,
Rachel

 

1 ACCEPTED SOLUTION

I figured out the auto populate issue.

I needed to create a read acl on sys.user_department so that our non-licensed users can submit.
The auto populate feature is now working for all users.

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

Make sure 'new_hire' is a reference field to user table. Also I think you are suppose to use department field which is available in user table. And the use the right variable name that you would like to set in the form.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

 

// autoPopulate is our callback function
g_form.getReference('new_hire', autoPopulate);
}

 

function autoPopulate(et) {
//set values after getting reference
g_form.setValue('<variable name>', et.getValue('department'));
}

Please mark this response as correct or helpful if it assisted you with your question.

Saloni Suthar
Mega Sage
Mega Sage

Hi @rachelconstanti ,

 

Sanjiv's suggestion in the script should work. However, If you are on Utah release, there is an Autopopulate tab. The tab lets you auto populate variable. Please review this link for more information.


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

I figured out the auto populate issue.

I needed to create a read acl on sys.user_department so that our non-licensed users can submit.
The auto populate feature is now working for all users.