I need to auto populate fields based on Requested for field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 07:20 AM
Hello I need to Auto populate these fields Manager, Email & Business Phone from the User table when anyone selects a user in the the Requested For field of this Catalog Item.
They need to change every time a different user is selected in the "Who is this request for?" field which fall under the "requested for" type. I know I need a client script probably, but any OOB ideas would be great to. Please I need step by step guidance, scripts or photos. Not links.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 07:47 AM
So for my particular situation. Would my script look like this:
var user = g_form.getReference('requested_for' , callBack);
Function Callback(user) {
g_form.setValue('business_phone' , user.business_phone);
g_form.setValue('manager' , user.manager);
g_form.setValue('email' , user.email);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 07:48 AM
var user = g_form.getReference('requested_for' , callBack);
Function Callback(user) {
g_form.setValue('business_phone' , user.phone);
g_form.setValue('manager' , user.manager);
g_form.setValue('email' , user.email);
The business phone field on user table is just named phone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 08:12 AM
Unfortunately, neither one of the scripts are working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 08:27 AM
So on the on change one you need to set the variable target to the variable that you are using for the requested for. See example here called variable name
Then the script below works for me in a dev instance
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = g_form.getReference('requested_for' , callBack);
Function Callback(user) {
g_form.setValue('business_phone' , user.phone);
g_form.setValue('manager' , user.manager);
g_form.setValue('email' , user.email);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 08:36 AM