Auto-populate field from User table into Catalog Item Variable

tom the
Giga Guru

Hi, People

 

I have created this Catalog Item, the variables above the green line are in a variable set, and the users_network_id field is a regular variable within the Catalog Item

tomthe_0-1740069403181.png

Field type

tomthe_1-1740069545563.png

Variable set field type

tomthe_2-1740069585978.png

I need to auto-populate the info on those fields based on the 'requested for' variable which is a reference to the sys_user table 

User network ID: should get the information from the custom field 'u_string_1'

 

***I was able to solve it using the auto-populate tab when setting the variable, but the challenge is not to use that method

 

Looking over, I found out it should be done with a Catalog Client Script. I have tried, but it's still not working. I don't know if the Script is missing.

 

Thank you in advance!

1 ACCEPTED SOLUTION

tom the
Giga Guru

Update... sorry, my fault I was using the wrong name for 'requested_for' I set it as 'resquestor_for', I fix that name and now it is working.

But there is a detail... the location is displaying as undefined

tomthe_1-1740072217915.png

tomthe_2-1740072462451.png

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var result = g_form.getReference('requested_for', requestorInfo);

    function requestorInfo(result) {
        g_form.setValue('requestor_first_name', result.first_name);
        g_form.setValue('requestor_last_name', result.last_name);
        g_form.setValue('requestor_email', result.email);
        g_form.setValue('requestor_middle_name', result.middle_name);
        g_form.setValue('requestor_location', result.location.name);
        g_form.setValue('requestor_contact_no', result.mobile_phone);
        g_form.setValue('requestor_position_title', result.title);
        g_form.setValue('users_network_id', result.u_string_1);
        g_form.setValue('requestor_employee_number', result.employee_number);
    }
}
 
how can I get Location to display as properly

View solution in original post

1 REPLY 1

tom the
Giga Guru

Update... sorry, my fault I was using the wrong name for 'requested_for' I set it as 'resquestor_for', I fix that name and now it is working.

But there is a detail... the location is displaying as undefined

tomthe_1-1740072217915.png

tomthe_2-1740072462451.png

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var result = g_form.getReference('requested_for', requestorInfo);

    function requestorInfo(result) {
        g_form.setValue('requestor_first_name', result.first_name);
        g_form.setValue('requestor_last_name', result.last_name);
        g_form.setValue('requestor_email', result.email);
        g_form.setValue('requestor_middle_name', result.middle_name);
        g_form.setValue('requestor_location', result.location.name);
        g_form.setValue('requestor_contact_no', result.mobile_phone);
        g_form.setValue('requestor_position_title', result.title);
        g_form.setValue('users_network_id', result.u_string_1);
        g_form.setValue('requestor_employee_number', result.employee_number);
    }
}
 
how can I get Location to display as properly