Method for checking for mandatory attachment on catalog item that utilizes best practices

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 12:47 PM - edited ‎06-26-2025 07:29 AM
I just spent the last 3 hours going down every path I could imagine, but could not find any solutions to meet these requirements.
- Require mandatory attachment on catalog item and prevent submission without it.
- Must use best practices; no DOM.
- Must use record attachment, no attachment variable. (This needs to be retrofitted into existing process that is using the record attachment)
- Attachment is mandatory only given a condition (not always mandatory, thus dont use Mandatory Attachment in portal settings);
I've tried everything imaginable and ran into road blocks everywhere:
- getCurrentAttachmentNumber() does not work in service portal
- GlideAjax to check sys_attachment table
- This requires requires cart item sys_id.
- g_form.getParameter("sysparm_item_guid") does not work in service portal.
- KB0723775 says to use g_form.getUniqueValue() but that is not helpful at all as g_form.getUniqueValue(); returns Catalog Item sys_id, not the Cart Item sys_id.
- Even after creating script include that takes Catalog Item sys_id as input, which is risky in its own, I still cant use a On Submit client script with Glide Ajax because you cant return false from an async callback on ga.getXMLAnswer() and ga.getXMLWait() is no longer supported.
- This requires requires cart item sys_id.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2025 12:59 PM
Hi @Jon Ulrich These are the possible ways, check this post
Possible Ways for Making an Attachment Mandatory :... - ServiceNow Community