- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
we have following onsubmit client script which is working fine for attachment validation on esc portal and native ui but its failing to check attachment when the same catalog item is opened in VA
function onSubmit() {
try {
var url = top.location.href;
if (url.indexOf("/esc") >= 0 || url.indexOf('/sp') >= 0) {
var portalAttachments = top.document.querySelectorAll(".list-group-item");
// if (portalAttachments.length > 0) {
if (portalAttachments.length) {
return true;
} else {
g_form.addErrorMessage("---Please attach at least one file before submitting."); //this is running on VA as error message , means its not able to check attachment
return false;
}
} else {
var nativeAttachments = top.document.querySelectorAll(".attachment_list_items > span");
if (nativeAttachments.length > 0) {
return true;
} else {
g_form.addErrorMessage("Please attach at least one file before submitting.");
return false;
}
}
} catch (e) {
g_form.addErrorMessage("Error while fetching attachment(s)");
return false;
}
}
This item and client script is Va compatible and so its opening in VA where due to this above script user is not able to submit from VA.
I checked the attachment related KB articles.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1585616
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0953692
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
From VA you can only submit catalog items which are simple without any script, UI policy etc
this KB tells it clearly
Not getting to submit catalog items from Virtual agent that have Catalog client script.
check this for better explanation
Now Assist in Conversational Catalog Request: Guidance for making catalog items conversational
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
3 weeks ago
Hi,
I believe that client scripts that uses DOM will not work in VA.
The same behaviour will probably happen if you were to test this item in a Workspace view.
You will need another way to validate that the user has submitted one or more attachments.
There is a "mandatory attachment" checkbox on the catalog item form you can use for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
From VA you can only submit catalog items which are simple without any script, UI policy etc
this KB tells it clearly
Not getting to submit catalog items from Virtual agent that have Catalog client script.
check this for better explanation
Now Assist in Conversational Catalog Request: Guidance for making catalog items conversational
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
3 weeks ago
hi @Ankur Bawiskar , Thanks for your response with documentation. We changed our approach and forced the results to open in browser instead of in VA itself.