cancel
Showing results for 
Search instead for 
Did you mean: 
chuckleung
Nintex Newbie

Nintex Form attachment size validation and control

Jump to solution

Hi everyone,

We are thinking about how to separate the attachment file size from SharePoint size imitation. For example, The SharePoint maximum upload file size is 50 MB but I need to control the attachment size to 5MB in Nintex Form. However, I cannot find any OOTB method to control the file size. Can anyone suggest other ways to achieve it?

Labels: (1)
0 Kudos
Reply
23 Replies
Automation Master
Automation Master

Re: Nintex Form attachment size validation and control

Jump to solution
0 Kudos
Reply
chuckleung
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution

Thanks for your reply, I had read this discussion before. However, when I put ‌ code to my Nintex 2016, the form cannot be opened and stuck in the loading icon. 

Can anyone suggest another way to deal with it? Thanks

0 Kudos
Reply
Automation Master
Automation Master

Re: Nintex Form attachment size validation and control

Jump to solution

I guess you mean Mark Altman‌'s script..

I've tried that script and noticed there is missing one closing brace there.

as well check for case when there is not any file attached needed little extend.

finally I reverted what value is returned in what case so that it is easier to use in validation rules

try following version

function IsFileSizeExceeded(maxSizeInMB) {
    var isValid=false;
    for ( var i=0; i<NWF$('input[type=file]').length; i++ )  {
        if(NWF$('input[type=file]')[i].files.length>0 && NWF$('input[type=file]')[i].files[0]!==null && NWF$('input[type=file]')[i].files[0]!==undefined) {
             if(NWF$('input[type=file]')[i].files[0].size>(maxSizeInMB*1048600)) {
                var sizeInMB = Math.round(NWF$('input[type=file]')[i].files[0].size / 10486) / 100; // # MB with two decimal places
                isValid=true;
                alert("The maximum file size is "+maxSizeInMB+"MB, but the file " + NWF$('input[type=file')[i].files[0].name + " is " + sizeInMB + "MB. Please reduce the file size before uploading.");
                break;
            }
        }
    }
    return isValid;
}

I used it as follows

View solution in original post

Reply
chuckleung
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution

Thanks @marian hatala. You save me.

Reply
fmorales
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution

This script is for 1mb, where or how change a 15mb for example???

Thanks

Federico MS.

Reply
Automation Master
Automation Master

Re: Nintex Form attachment size validation and control

Jump to solution

max allowed size is determined by input paramter of IsFileSizeExceeded() function.

Reply
fmorales
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution

Thanks.

FMS.

Reply
shdb1004
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution

This works great. but it seems that it validate the size of each uploaded file.

in my case I need to know the total of all uploaded files in one attachment control. the reason is to attach them in emails. 

any help?. I'm no good with JS.

kindly, vote for this update: Validate the max size of attachment control – Customer Feedback for Nintex 

0 Kudos
Reply
hema2930
Nintex Newbie

Re: Nintex Form attachment size validation and control

Jump to solution
Hi Emha,

This code is blocking the saving of an attachment in IE. How to over come from this?

Regards,
Hema
0 Kudos
Reply