Not able to add multiple attachments in one catalog form due to client script

sri vijaya
Tera Contributor

Hi ,

In catalog form, we are unable to add multiple attachments due to one catalog client script, if we are adding more than one attachment it is giving us the error as "Please attach the necessary attachment" as we have configured in catalog client script as it is taking only one attachment

i have changed some changes to script but its not working fine

Pasting the onsubmit catalog client script  here which  we are using for this catalog form

Please help me to resolve this issue like in script where i am going incorrect

Onsubmit catalog client script : 

 

function onSubmit() {
var typeCondition = 0;
var topic = g_form.getValue('u_topic');
if (topic == "I have an overpayment" || topic == "I have an underpayment" || topic == "I have not received any payment" || topic == "Resignations/terminations" || topic == "I can't access my payslip" || topic == "Add/remove beneficiaries Colmedica" || topic == "Add tax relief"|| topic == "Change of hierarchy"|| topic == "Request bank account change"|| topic == "Request cesantias") {
typeCondition = 1;
}
var reqAttachments = typeCondition;
if (reqAttachments > 0) {
try {
var attachments = document.getElementsByClassName('attachment_list_items');
if (attachments.length - 1 != reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
} catch (e) {
var count = getSCAttachmentCount();
if (count != reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
}

}
}

@Peter Bodelier @AnveshKumar M @Vishal Birajdar 

 

1 ACCEPTED SOLUTION

Peter Bodelier
Giga Sage

Hi @sri vijaya,

 

You are checking if the count of attachments is the same as the required amount. You should check if it's at least the required amount;

function onSubmit() {
var typeCondition = 0;
var topic = g_form.getValue('u_topic');
if (topic == "I have an overpayment" || topic == "I have an underpayment" || topic == "I have not received any payment" || topic == "Resignations/terminations" || topic == "I can't access my payslip" || topic == "Add/remove beneficiaries Colmedica" || topic == "Add tax relief"|| topic == "Change of hierarchy"|| topic == "Request bank account change"|| topic == "Request cesantias") {
typeCondition = 1;
}
var reqAttachments = typeCondition;
if (reqAttachments > 0) {
try {
var attachments = document.getElementsByClassName('attachment_list_items');
if (attachments.length - 1 < reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
} catch (e) {
var count = getSCAttachmentCount();
if (count < reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
}

}
}

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @sri vijaya,

 

You are checking if the count of attachments is the same as the required amount. You should check if it's at least the required amount;

function onSubmit() {
var typeCondition = 0;
var topic = g_form.getValue('u_topic');
if (topic == "I have an overpayment" || topic == "I have an underpayment" || topic == "I have not received any payment" || topic == "Resignations/terminations" || topic == "I can't access my payslip" || topic == "Add/remove beneficiaries Colmedica" || topic == "Add tax relief"|| topic == "Change of hierarchy"|| topic == "Request bank account change"|| topic == "Request cesantias") {
typeCondition = 1;
}
var reqAttachments = typeCondition;
if (reqAttachments > 0) {
try {
var attachments = document.getElementsByClassName('attachment_list_items');
if (attachments.length - 1 < reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
} catch (e) {
var count = getSCAttachmentCount();
if (count < reqAttachments) {
alert('Please attach the necessary attachment');
return false;
}
}

}
}

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.