Why g_scratchpad returning undefined value??

KM SN
Tera Expert

I just want to pass assigned to information from server side to client script so that when i change incident assigned to  value description should take the value as shown in below pictures but its showing undefined.

 

what went wrong? where modification should happen? any suggestions!!

 

 

business rule.PNGPractice.PNGresult.PNG

1 ACCEPTED SOLUTION

sushantmalsure
Mega Sage
Mega Sage

@KM SN 

I think the time display BR ran, assigned to field was not populated and that may be the reason to have undefined value in short description you are setting from client script.

 

For this case you may not need display BR and setting the value from scratch pad variable, you can do it just using onChange() client script.

Modify the your existing onChange() client script and deactivate display BR.

Script to add in onChange() client script:

 

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

    if (newValue != oldValue) {
var getDetail = g_form.getReference('assigned_to',currentUser1);
		return;
    }
	
}
	function currentUser1(getDetail){
		g_form.setValue('short_description','Assigned to Title is '+getDetail.title+' email is '+getDetail.email);
	}

    //Type appropriate comment here, and begin script below

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

4 REPLIES 4

saichand1
Tera Contributor

Hi Mani

 

Instead of g_scratch pad use call back function in client script itself

 

var assigned = g_form.getReference('assigned_to', callback);
function callback(assigned) {

var email=assigned.email;

var title = assigned.title;

g_form.setValue('short_description',"Assigned to Title:"+title+"and email is:"+email);

}

saichand1
Tera Contributor

i have made a small correction in the script 

var assigned = g_form.getReference('assigned_to', callback);
function callback(assigned) {

var email=assigned.email;

var title = assigned.title;

g_form.setValue('short_description',"Assigned to Title:"+title+"and email is:"+email);

}

sushantmalsure
Mega Sage
Mega Sage

@KM SN 

I think the time display BR ran, assigned to field was not populated and that may be the reason to have undefined value in short description you are setting from client script.

 

For this case you may not need display BR and setting the value from scratch pad variable, you can do it just using onChange() client script.

Modify the your existing onChange() client script and deactivate display BR.

Script to add in onChange() client script:

 

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

    if (newValue != oldValue) {
var getDetail = g_form.getReference('assigned_to',currentUser1);
		return;
    }
	
}
	function currentUser1(getDetail){
		g_form.setValue('short_description','Assigned to Title is '+getDetail.title+' email is '+getDetail.email);
	}

    //Type appropriate comment here, and begin script below

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

KM SN
Tera Expert

I want to do this through BR only. Yes! you are right as you said display business rule is not triggering when we change the value of field as by default display br will trigger whenever display the info through form.

 

Any how thanks for the inputs.