getSCAttachmentCount() is getting error in my portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:35 AM
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:
Can someone help me with that.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:40 AM
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;
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:52 AM
Its still not working. The same error is generated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:58 AM
Share your client script screenshot.
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 03:09 AM