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

Harish KM
Kilo Patron
Kilo Patron

Hi  The below script will work

        try {
            var alertWord = "Attachment Mandatory.";
            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

Its still not working. The same error is generated.

Share your client script  screenshot. 

Regards
Harish

find_real_file.png