Auto-populate fields based on user picked

Matthew13
Mega Contributor

What I want to do is to populate the manager/supervisor, location, phone number, and e-mail fields once a user is chosen.

find_real_file.png

I have been trying to grab fields, but I am coming up with an error when I am trying to figure out the manager field.

TypeError: Cannot read properties of undefined (reading 'hiring_manager_supervisor_name')
function onLoad() {
    var user = g_form.getReference('name');
    jslog("********This message is from jslog().********");
    jslog("Manager value = " + g_form.getValue('hiring_manager_supervisor_name', user.hiring_manager_supervisor_name));
    jslog("This is the user." + g_user.getFullName());
    jslog("********This message is from jslog().********");
}

I am using the onLoad function to see if I am able to grab values via debugging. I do know it should be an onChange function, but when I was trying to debug with JSlog, it would not populate the console. Is there a better way to test?

Any ideas on how I can get the values of the user's information? I feel as though I am calling on the wrong variable at the moment.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi Matthew,

You can use this Article for your requirement by Mark:

Catalog Data Lookup Definition on any table, eliminating Catalog Client Scripting

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

View solution in original post

5 REPLIES 5

SumanthDosapati
Mega Sage
Mega Sage

Hi,

1) You can use g_form.addInfoMessage() also for debugging

2) You are using getValue instead of setValue 

3) OnLoad if the name field is empty then you cannot set it based on that field. You definitely need onChange.

 

Regards,
Sumanth