Record Producer

pansarepooj
Tera Contributor

onSubmit script error: TypeError: Cannot read properties of null (reading 'textContent'):
function default_on_submit() {
    if (!g_form)
        return true;
    return g_form.onSubmit();
}

 

 

Hi, I am trying to do some modification in Record Producer and its giving me this error how to fix this issue?

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@pansarepooj 

please share your complete business requirement and the script you are using to achieve that

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

snehareddym
Tera Expert

The error you're getting indicates that you're trying to access a DOM element that doesn't exist at runtime. In ServiceNow, it's not recommended to use document.getElementById() or textContent directly, especially in Record Producers or Catalog Items.

Instead, please use g_form.getValue('field_name') or g_form.getElement('field_name') if absolutely needed.

Also, can you share where you're using this onSubmit script (Client Script or elsewhere), and which element you’re trying to access? That’ll help narrow down the issue.