I got onSubmit script error: TypeError: Cannot read property 'value' of undefined:

pavni
Tera Contributor

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;
}
}

}

4 REPLIES 4

Raj68
Mega Guru

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

 

pavni
Tera Contributor

i have resolved thi by keeping null check. thanks. 

Hi Pavni, I'm having a similar issue. Could I check how you resolved it?

 

Regards,
Murali

Omkar Mone
Mega Sage

Hi 

Try something like this :-

 

var assignment= g_form.getReference('assignment_group', doAlert);

function doAlert(assignment) {

 

alert(assignment.name);

 

}