Getting onSubmit error when submitting a catalog item

Saquib Mohammed
Mega Guru

Hi

I am getting below error when trying to submit a catalog form - 

onSubmit() script error:TypeError: Cannot read properties of null (reading: 'document');

function() native code] }

 

The code snippet is below -

function onSubmit() {
   var condition = g_form.getValue('mailbox_owner_approval');
   if (condition == 'Yes') // Shared Mailbox
{
        var countRequired = 1; // define the total no.of attachments to be attached before submit
        if (window == null) {
            // portal
            if (this.document.getElementsByClassName('get-attachment').length != countRequired) {
                alert('You must add attachments before submitting this request.');
                return false;
            }
        } else {
            // native view
            var length = $j("li.attachment_list_items").find("span").length;
            if (length != countRequired) {
                alert('You must add attachments before submitting this request.');
                return false;
            }
        }
 
    }
}
1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

For client scripts there is a check box called Isolate script. It is not on the form by default but in the case of your script it needs to be set to false. You can add it to the form or list layout to set it to false.

View solution in original post

1 REPLY 1

Brian Lancaster
Tera Sage

For client scripts there is a check box called Isolate script. It is not on the form by default but in the case of your script it needs to be set to false. You can add it to the form or list layout to set it to false.