I got onSubmit script error: TypeError: Cannot read property 'value' of undefined:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2018 01:48 AM
I got onSubmit script error: TypeError: Cannot read property 'value' of undefined: when i am modifiying the incident view from self-service to default view.
below is my code: this code is doing when p5 allowing to submit incident else it'snot
function onSubmit() {
var incSupportGroup = g_form.getDisplayBox('assignment_group').value;
var incPriority = g_form.getValue('priority');
if((incPriority == '5'))
{ if((incSupportGroup.indexOf('Wipro')>-1))
{
return true;
}
else
{
alert("Non-Wipro Support groups are not allowed to submit incidents using Priority 'P5 - Non urgent'. Please change the priority before submitting the incident.");
return false;
}
}
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2018 02:13 AM
Hi pavni,
go through below link may be it will help you:
The above error was removed after modifying onSubmit Client script as below.
function onSubmit() {
//Type appropriate comment here, and begin script below
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach document before submitting the request.');
return false;
}
https://community.servicenow.com/community?id=community_question&sys_id=cdf70f2ddb1cdbc01dcaf3231f96190a&view_source=searchResult
NOTE: Mark correct or helpful if it helps you.
Warm Regards,
Raj patel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2018 02:19 AM
i have resolved thi by keeping null check. thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2019 10:38 PM
Hi Pavni, I'm having a similar issue. Could I check how you resolved it?
Regards,
Murali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2018 02:22 AM
Hi
Try something like this :-
var assignment= g_form.getReference('assignment_group', doAlert);
function doAlert(assignment) {
alert(assignment.name);
}