Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 11:23 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 11:30 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 11:33 PM
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.