getSCAttachmentCount() is getting error in my portal

vvr0409
Giga Contributor

getSCAttachmentCount(); is not working for me. I copied same code from the community, still not working.

onSubmit Client Script code:

function onSubmit() {
    try {
        var attachmentList = gel("header_attachment_list_label");
        if (attachmentList) {
            if (attachmentList.style.visibility == "hidden" || attachmentList.style.display == "none") {
                if (confirm("message")) {
                    return true;
                } else
                    return false;
            }
        }
    } catch (e) { //For Service Portal
        var count = getSCAttachmentCount();
        if (count <= 0) {
            if (confirm("message")) {
                return true;
            } else
                return false;
        }
    }
}

And I added UI script as follows:

function getSCAttachmentCount() {
    var length;
    try {
        length = angular.element("#sc_cat_item").scope().attachments.length;
    } catch (e) {
        length = -1;
    }
    return length;
}

Still I got the error message in console like this:

find_real_file.png

find_real_file.png

Can someone help me with that.

12 REPLIES 12

Hi can you uncheck Isolate script checkbox to false save and re try?

Regards
Harish

Still getting same error.

 

Replace this. I tested works good for me in PDI

function onSubmit() {
    

        
        var alertWord = "Please use the paperclip icon below to attach receipts before submitting the request.";
        
        try {
            var attachments = g_form.getControl('header_attachment_list_label');
            if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
                alert(alertWord);
                return false;
            }
            
        } catch (e) { //For Service Portal
            
            var count = getSCAttachmentCount();
            
            if (count <= 0) {
                alert(alertWord);
                return false;
            }
        }
    }
   

Regards
Harish

If script doesnt work you can go to catalog form under portal setting

Mandatory Attachment check box set this as true.

Refer attached screenshot

Regards
Harish

Chandu Telu
Tera Guru
Tera Guru

Hi,

I am not sure from where did you copied but the issue - onsubmit client script have  "getSCAttachmentCount" method add the all code in onsubmit client script

 

Thanks
Chandu Telu
Please Mark Correct/helpful, if applicable,