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 03:42 AM
Hello
Did you add this UI script as JS include in your portal record before executing the client script. If not follow below steps
1) Type in portals
2) Open your portal record and open theme record tagged in theme column
3) Scroll down and create a new record under JS Includes related list
4) After clicking on new tag your UI script like below
Then check if your client script is working or not
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 03:46 AM
I have added the UI script in JS includes, but still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 03:54 AM
Hello
I think you want it to work on both native and portal view
Make sure you selected Type as ALL in the on submit client script
and follow this article this is a clear cut explanation for your requirement
Please mark my answer correct if it helps you