- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
58m ago - last edited 56m ago
Hi @Naresh_5120 ,
This can be done without any script as well if you want to. What you need to do is:
1) Create a UI Policy for the Yes/No field and in the 'When' condition mention the value to be 'Yes'
2) In the UI policy action, select the attachment variable and make 'mandatory' option as true.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
