getSCAttachmentCount(); function is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:02 AM
Hi,
We have an 'on submit' client script for making the attachment mandatory in portal.
Even after adding attachment also, the alert is showing like 'Please attach attachements'.
Can anyone help me?
We have used the below script
function onSubmit() {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('Please attach attachements');
return false;
}
} catch(e) {
var count = getSCAttachmentCount();
if(count <= 0) {
alert('Please attach attachements');
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:38 AM
Hi @Pavan S
Refer below link
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743672
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:42 AM
Hi Dgarad,
We have made the changes as per the KB mentioned only. Still it is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 05:04 AM
var attachments = document.getElementById('header_attachment_list_label');
replace below code check
var attachments = g_form.getControl('header_attachment_list_label');
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:50 AM
Hi @Pavan S ,
I see usage of DOM manipulation, for this you need to check "Isolate Script" to true is that checked in your script.
Please mark helpful/correct if my response helped you.