The CreatorCon Call for Content is officially open! Get started here.

how to set Department value using client script type getReference

Amit Arya1
Tera Contributor

when using  below client script then giving sysid of Department not display value & other fields are populating correct.

 

 

 

 

var id = g_form.getReference("caller_id", data_function);

    function data_function(id) { 
        g_form.setValue("u_department", id.department);
        g_form.setValue("u_mobile", id.mobile_number);
    }

 

 

 

@Bimlakar Singh   @Bimlakar Singh1 - Please help asap.

1 ACCEPTED SOLUTION

Bimlakar Singh
Tera Expert

Hi @Amit Arya1 

 

If you are populating any reference fields table that again references any other table then you can go with method 1 & few more to use in your best practice.

 

Method 1

//if using any reference field on the referencing table

 var id = g_form.getReference("caller_id", data_function);

    function data_function(id) {
        var gr = new GlideRecord("cmn_department");
        gr.get(id.department);
        g_form.setValue("u_department", gr.name);
        g_form.setValue("u_email", id.email);
        g_form.setValue("u_mobile", id.mobile_number);
    }

Method 2

 var id = g_form.getReference("caller_id", data_function);

    function data_function(id) { 
        g_form.setValue("u_email", id.email);
        g_form.setValue("u_mobile", id.mobile_number);
    }

Method 3

var user_email = g_form.getReference("caller_id").email;
g_form.setValue("u_email",user_email);

Method 4

g_form.setValue("u_email",g_form.getReference("caller_id").email);

 

View solution in original post

2 REPLIES 2

Bimlakar Singh
Tera Expert

Hi @Amit Arya1 

 

If you are populating any reference fields table that again references any other table then you can go with method 1 & few more to use in your best practice.

 

Method 1

//if using any reference field on the referencing table

 var id = g_form.getReference("caller_id", data_function);

    function data_function(id) {
        var gr = new GlideRecord("cmn_department");
        gr.get(id.department);
        g_form.setValue("u_department", gr.name);
        g_form.setValue("u_email", id.email);
        g_form.setValue("u_mobile", id.mobile_number);
    }

Method 2

 var id = g_form.getReference("caller_id", data_function);

    function data_function(id) { 
        g_form.setValue("u_email", id.email);
        g_form.setValue("u_mobile", id.mobile_number);
    }

Method 3

var user_email = g_form.getReference("caller_id").email;
g_form.setValue("u_email",user_email);

Method 4

g_form.setValue("u_email",g_form.getReference("caller_id").email);

 

Amit Arya1
Tera Contributor

Thank you so much Bimlakar