How can I make attachment mandatory in condition.

Chandra18
Mega Sage

suppose We have 4 checkbox variable in catalog form.

name of checkbox variable is A,B,C & D.   AND   checkbox A will always ticked.

Make attachment mandatory only in another check box next to "A" is ticked(B or C or D anyone or ALL)


find_real_file.png

Thank you!

1 REPLY 1

Suseela Peddise
Kilo Sage

Hi,

To make attachment mandatory in all conditions, you can use OOB 'Mandatory Attachment' field on catalog item. To make attachment mandatory based on other catalog variable, please go through below link

SERVICE PORTAL: REQUIRE ATTACHMENTS

Add extra condition in client script to check the variable values, see the first if condition and update the variable names

function onSubmit() {

if(g_form.getValue('b')=='true' ||g_form.getValue('c')=='true'){ //update field values
//Works in non-portal ui
try {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach a document before submitting this request.');
return false;
}
}
//For Service Portal
catch(e) {
var count = getSCAttachmentCount();
if(count <= 0) {
alert('You must attach a document before submitting this request.');
return false;
}
}
}

}

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.