cmikhaiel_e
Workflow Hero

Make attachments required on condition

Jump to solution

I'm implementing an expense claim. And the users are required to attach a receipt except if they are only claiming mileage. How do I create a condition on the attachments to be required if they select yes on a "yes/no - Mileage Only" field.

I tried to put a rule on the attachments to make it disabled if the user selects mileage only=yes. But how do i make it required to complete if mileage only=No?!

I found earlier an article here that explains how to make fields required on a single line of text but it doesn't apply the same way on "attachments" as there is no named control for attachments. I also don't want to disable the save button, i need it to give an error message to the user to explain what is missing.

 

Help!! 

0 Kudos
Reply
16 Replies
murphybp2
Cloud Wanderer

Re: Make attachments required on condition

Jump to solution

This question looks similar.  They used a script to validate the attachment in certain scenarios. You would just need to modify the script to your conditions.

Reply
cmikhaiel_e
Workflow Hero

Re: Make attachments required on condition

Jump to solution

Thanks Brendan. I haven't written java script before. would you be able to take a look at this and let me know if that would work? given that mileageonly is a yes/no field and that i want the attachment to be required when it is marked as "No".

function validateAttachments(source, arguments)
{
    var elm = NWF$('.nf-attachmentsTable');
    var mileValue = NWF$('#' + mileageonly).val();  
    arguments.IsValid = true;
    if (milevalue == 'false' )  {
        if (elm.length > 0 && elm.find('tr').length >= 1) {
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
    }
}

appreciate the help

Reply
murphybp2
Cloud Wanderer

Re: Make attachments required on condition

Jump to solution

Unfortunately I don't have much experience with JS either.     I'd suggest trial/error and see if it works.  

0 Kudos
Reply
cmikhaiel_e
Workflow Hero

Re: Make attachments required on condition

Jump to solution

Not a problem. Thanks for your reply

0 Kudos
Reply
emha
Automation Master
Automation Master
cmikhaiel_e
Workflow Hero

Re: Make attachments required on condition

Jump to solution

Thanks Marian. Would you kindly show me an actual example of how you get the AttachmentsClassId or class name? I tried to insert the .nf-attachmentstable, I tried the guid(id) from the source of the page. but I can't get it to validate and work. it is still allowing the user to save the form.

HELP!!! I need to get this out of the way, it has been 2 days already spent on 1 validation 😞

0 Kudos
Reply
emha
Automation Master
Automation Master

Re: Make attachments required on condition

Jump to solution

it's one that you can configure in control settings on your own...

0 Kudos
Reply
emha
Automation Master
Automation Master

Re: Make attachments required on condition

Jump to solution

Hi ‌,

have you managed to resolve your problem?

if so, could you mark the question answered?

#BRGreview‌

0 Kudos
Reply
cmikhaiel_e
Workflow Hero

Re: Make attachments required on condition

Jump to solution

Thanks Marian Hatala‌ for the reminder . and apologies on the delayed response.

I did solve it by adding a function into the min attachments field. It doesn't perfectly work fine in all cases, but I can live with it.

0 Kudos
Reply