- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 11:56 AM
Mandatory attachment check is not working on order guides in service portal, keep asking for the attachments over and over and not letting to proceed further.Any help on here is greatly appreciated.
Here is the code that i'm using, which is working fine for stand alone catalog items on both iframe and service-portal but not on order guides in service-portal.
UI Script: GlobalCatalogItemFunctions
function getSCAttachmentCount() {
var length;
try {
length = angular.element("#sc_cat_item").scope().attachments.length;
} catch(e) {
length = -1;
}
return length;
}
This is an onSubmit script I am using for a catalog item:
function onSubmit() {
try { //Works in non-portal ui
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach the completed form before submitting this request.');
return false;
}
} catch(e) { //For Service Portal
var count = getSCAttachmentCount();
if(count <= 0) {
alert('You must attach the completed form before submitting this request.');
return false;
}
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2018 10:43 AM
i got it worked with this code, might be useful for somebody who's looking for it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 12:37 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 12:42 PM
Hi
Try to use onSubmit script
function onSubmit() {
try { //Works in non-portal ui
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach the completed form before submitting this request);
return false;
}
} catch(e) { //For Service Portal
var count = getSCAttachmentCount();
if(count <= 0) {
alert('You must attach the completed form before submitting this request');
return false;
}
}
}
And please make sure your UI type is ALL to work in service portal.
Please let me know if you have any questions.
Thanks,
Please Hit like, Helpful or Correct depending on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 01:00 PM
Hello Chaitanya,
Thanks for the reply!
i'm also using the same script, which is not working for order guides in service-portal and UI type is all for my client script
In the below UI Script that we are calling from client script is not able to find sc_cat_item element for order guides and its getting failed in try block and going to catch.
UI Script: GlobalCatalogItemFunctions
function getSCAttachmentCount() {
var length;
try {
length = angular.element("#sc_cat_item").scope().attachments.length;
} catch(e) {
length = -1;
}
return length;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2018 01:12 PM
Change #sc_cat_item to #sc_cat_item_guide in your code