Mandatory Attachment on Submit based on Catalog Item Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2019 03:14 PM
Hello all,
I have a requirement to make an attachment mandatory on submit based on a catalog item variable.
The question is: Are you requesting to relocate more than one phone? (relocate_phone)
If yes: attachment is required
If no: attachment is not required
In the past when making an attachment mandatory in a catalog task I have used business rules or catalog client scripts but in this case I cannot figure it out.
Can anyone assist?
Thanks,
Grace
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2019 03:24 PM
try something like
function onSubmit() {
var count = getSCAttachmentCount();
if(g_form.getValue('youryesno field name') == 'yes'){
if(count <= 0) {
alert('Please attach your spreadsheet.');
g_form.addErrorMessage('Please attach your spreadsheet.');
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2019 03:51 PM
Thanks for the reply Mike!
I tried your solution and it won't allow the user to submit for either option and no alert message is displayed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2019 03:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2019 04:06 PM
Yes I have the below and no we are not on the service portal yet: