- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 05:38 AM
Hi Team ,
can any one please correct my script .
For a particular catalog item , attachment should become mandotory , with out attchment request should not be submit , it is should abort subimission with error an message , please provide cilent script and script include which should as per the requirment
I have written onsubmit cilent script and script include
script include
type: 'AttachmentChecker'
};
while testing , without attachment request is submitting .
what whas the issue in my script please correct
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 05:58 AM
check this and create catalog onSubmit script and it will work in both native + portal
function onSubmit() {
//Type appropriate comment here, and begin script below
try {
if (window == null) {
// portal
if (this.document.getElementsByClassName('get-attachment').length == 0) {
g_form.addErrorMessage("Please attach a file before submitting.");
return false;
}
}
} catch (ex) {
// native view
var length = getSCAttachmentCount();
if (length == 0) {
g_form.addErrorMessage("Please attach a file before submitting.");
return false;
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 05:58 AM
check this and create catalog onSubmit script and it will work in both native + portal
function onSubmit() {
//Type appropriate comment here, and begin script below
try {
if (window == null) {
// portal
if (this.document.getElementsByClassName('get-attachment').length == 0) {
g_form.addErrorMessage("Please attach a file before submitting.");
return false;
}
}
} catch (ex) {
// native view
var length = getSCAttachmentCount();
if (length == 0) {
g_form.addErrorMessage("Please attach a file before submitting.");
return false;
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 05:59 AM
your script uses getXMLWait() which is synchronous call and it won't work in portal
Use script I shared below and it will work in both native + portal
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader