Dot walking using getReference in Client Script

rpoola
Tera Contributor

Hi,

Following is my Client script where i am fetching details of reference field and copying to my current form fields. For one field I need to go two level dot walking which is not working.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading) {

                  return;

    }

    if (newValue === '') {

              g_form.setValue('u_company', '');

              g_form.setValue('u_billing_contact', '');

              g_form.setValue('invoice_fequency', '');

              g_form.setValue('u_approver', '');

              return;

    }

        var caller = g_form.getReference('u_placement', placDetails);

}

function placDetails(caller) { //reference is passed into callback as first arguments

        g_form.setValue('u_company', caller.u_company);

        g_form.setValue('u_billing_contact', caller.u_billing_contact);

        g_form.getReference('u_billing_contact', billingContact);

        g_form.setValue('assigned_to', getApprover(caller.u_approver)); // This is not working as I need to fetch second level field value of reference field in my current form

}

function billingContact(caller){

        g_form.setValue('invoice_fequency', caller.u_time_sheet_frequency);

}

function getApprover(caller){

        var gr = new GlideRecord('x_vsng2_bullhorn_bh_approver'); //GlideRecord is not working it seeems

        gr.addQuery('sys_id',caller);

        gr.query();

        if(gr.next()){

                  return gr.u_user;

        }

}