Client Script not working on Portal

Jeannette2
Tera Guru

I have a Client Script that works on Desktop but not the Portal.  I have tried it by setting UI Type to All and to Mobile / Service Portal.

I have also setup 2 Catalog Data Definitions that does the same thing as the Script but again it works on Desktop but not Portal.

Has anyone come across this?  Myself and a colleague have tried and looked at everything possible but still can't get it to work.

 

1 ACCEPTED SOLUTION

Hi,

GlideRecord won't work on portal and hence it's not working.

please use onChange with getReference callback and it will work in Native + Portal

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading) {
		return;
	}

	if(newValue == ''){
		g_form.clearValue('team');
		g_form.clearValue('department');
	}

	if(oldValue != newValue)
		var ref = g_form.getReference('name_of_new_starter', callBackMethod);
}

function callBackMethod(ref){
	if(ref.department)
		g_form.setValue('team',ref.department);

	if(ref.title)
		g_form.setValue('department', ref.title);

}

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

share the client script and script include code if you are using Ajax

share screenshots of form as well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

find_real_file.png

find_real_file.png

Hi,

GlideRecord won't work on portal and hence it's not working.

please use onChange with getReference callback and it will work in Native + Portal

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading) {
		return;
	}

	if(newValue == ''){
		g_form.clearValue('team');
		g_form.clearValue('department');
	}

	if(oldValue != newValue)
		var ref = g_form.getReference('name_of_new_starter', callBackMethod);
}

function callBackMethod(ref){
	if(ref.department)
		g_form.setValue('team',ref.department);

	if(ref.title)
		g_form.setValue('department', ref.title);

}

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur thank you so much!