What is causing - onSubmit script error: TypeError: Cannot read properties of null (reading 'text'):

MBarrott
Mega Sage

This script works for all my other tables but the problem table is causing issues. 

 

Getting error: onSubmit script error: TypeError: Cannot read properties of null (reading 'text'):
function () { [native code] }

 

Any idea as to why?

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
	var choiceValue = g_form.getValue('state');
	alert(choiceValue);
	alert('time is: ' + g_form.getValue('problem.time_worked'));
	var choiceLabel = g_form.getOption('state', choiceValue).text; // failing here
	alert(choiceLabel); // uncomment for testing purposes to see captured value
	
	if(g_form.getValue('problem.time_worked') == '00:00:00' && (choiceLabel == 'Resolved' || 
														choiceLabel == 'Deferred' || 
														choiceLabel == 'Closed Complete' || 
														choiceLabel == 'Closed Incomplete' || 
														choiceLabel == 'Closed Skipped' || 
														choiceLabel == 'Closed No Customer Response' || 
														choiceLabel == 'Duplicate Ticket' || 
														choiceLabel == 'Incorrect Ticket Type'))
	{
		alert('Please enter total time worked on this record.');
		return false;
	}
}

 

5 REPLIES 5

Jayant_M
Kilo Sage

Hi @MBarrott ,

try commenting line number 4, as dot walk is not allowed in client script .

i.e, 

alert('time is: ' + g_form.getValue('problem.time_worked'));

 

Please mark my response helpful if it resolves your issue

Hi @Jayant_M 

 

No change, still giving same error I'm afraid. 

Sandeep Rajput
Tera Patron
Tera Patron

@MBarrott You are trying to dot walk time_worked field on line number 5 

	alert('time is: ' + g_form.getValue('problem.time_worked'));

and on line number 7

	if(g_form.getValue('problem.time_worked') == '00:00:00' && (choiceLabel == 'Resolved' || 

 

Dot walk is not supported in client script. I recommend using getReference or GlideAjax API call to address this issue.

 

Hope this helps.

Hi @Sandeep Rajput

 

Error still displays when dot walking removed. 

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
	var choiceValue = g_form.getValue('state');
	var choiceLabel = g_form.getOption('state', choiceValue).text;
		
	if(g_form.getValue('time_worked') == '00:00:00' && (choiceLabel == 'Closed Complete' || 
														choiceLabel == 'Closed Incomplete' || 
														choiceLabel == 'Closed Skipped'))
	{
		alert('Please enter total time worked on this record.');
		return false;
	}
}