How to make " Add attachments" mandatory and prevent from submission based on Variable selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
45m ago
Dear Community,
I need some suggestion to make " Add attachments" mandatory in catalog item and prevent from submission the catalog item form based on Yes/NO Type Variable selection. If Variable called "do_have_approval" is Yes then make the " Add attachments" mandatory in catalog item and prevent from submission the catalog item form, if attachment is attached then allow to submit the form.
I am trying to achieve this through catalog client script but its not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
Hi @Naresh_5120 ,
I tried your problem in my PDI and it works for me please check solution below
I created 2 variables on my Catalog item 1. Is Approval(Yes/No), 2. Attachment (attachment type)
I created one OnSubmit Client script and add below code
function onSubmit() {
//Type appropriate comment here, and begin script below
var approval = g_form.getValue('is_approval'); // Yes/No variable
if (approval === 'Yes') {
var attCount = g_form.getControl('add_here').attachments
? g_form.getControl('add_here').attachments.length
: 0;
if (attCount === 0) {
g_form.addErrorMessage("Attachment is required when approval is Yes.");
return false;
}
}
return true;
}
Result
When I select yes and try to submit it shows me error
Please mark my answer correct and helpful if this works for you
Thanks and Regard,
Sarthak
