- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:01 AM
Hi All,
Can anyone help me, how to achieve the below requirement.
when we select the 'No' in yes/No type variable in catalog item then attachment needs to mandatory.
Attached the reference screenshot.
Thanks in advance,
Satya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:11 AM - edited 03-18-2024 10:19 AM
Hello you can create an on-submit client script to check if there is more than 1 attachment when the request is submitted or not.
Here is a sample:
function onSubmit() {
var answer =true;
if (g_form.getValue('your_field') == 'no')
{
if(this.document.getElementsByClassName('file-list-wrap').length == 0) {
g_form.addErrorMessage('PLEASE ATTACH THE REQUIRED FILE ');
answer= false;
}
}
return answer;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:06 AM
This might be helpful.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:08 AM - edited 03-20-2024 05:51 AM
Hi @Satya kolisetti ,
Try this code :
if (g_form.getValue('<yourfiled>') == 'no' && !(g_form.getAttachment().length == 0)) {
alert("Please attach the attachment");
return false;
}
return true;
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 10:11 AM - edited 03-18-2024 10:19 AM
Hello you can create an on-submit client script to check if there is more than 1 attachment when the request is submitted or not.
Here is a sample:
function onSubmit() {
var answer =true;
if (g_form.getValue('your_field') == 'no')
{
if(this.document.getElementsByClassName('file-list-wrap').length == 0) {
g_form.addErrorMessage('PLEASE ATTACH THE REQUIRED FILE ');
answer= false;
}
}
return answer;
}