What is causing - onSubmit script error: TypeError: Cannot read properties of null (reading 'text'):
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 08:37 AM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 09:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:10 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:15 AM
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;
}
}