on load client script

Anjali yadav1
Tera Contributor

hello every  I struck while onload client script

Anjaliyadav1_0-1714483603421.png

I'm getting the desired result with this script

desire result should be

 

Anjaliyadav1_1-1714483769001.png

 

pls help me....

 

2 REPLIES 2

Sujatha V M
Kilo Patron
Kilo Patron

@Anjali yadav1 Please use the below script to populate the values,

 

If caller is auto-populated then onLoad client script.

 

 

function onLoad() {
   //Type appropriate comment here, and begin script below   
    var caller = g_form.getReference('caller_id', setLocation);

function setLocation(caller) {
    if (caller)
    g_form.setValue('location', caller.location);
    g_form.setValue('department', caller.department); 
        //Add your necessary fields to set the value
}
}

 

If caller is changed then its onChange client script,

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
   }

    var caller = g_form.getReference('caller_id', setLocation);
}

function setLocation(caller) {
    if (caller)
        g_form.setValue('location', caller.location);
        g_form.setValue('department', caller.department);		
}

 

Result : 

SujathaVM_1-1714579775561.png

 

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

 

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Community Alums
Not applicable

Hi @Anjali yadav1 ,

Can you please try this script 

 

g_form.setValue('u_caller', g_user.userId)
var userref = g_form.getReference('u_caller', userLookup);
	  function userLookup(userref){
	    g_form.setValue('location', userref.location.toString());
	    g_form.setValue('location', userref.email);
	    g_form.setValue('location', userref.department);
	    g_form.setValue('location', userref.location.toString());
	  }

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak