Validating File Attributes

From SmartWiki
Jump to: navigation, search

Number of Pages

  • The number of pages that a PDF file in a Single File field contains can be evaluated as follows
  • This script will prevent saving or submitting a record unless there is a valid PDF stored in the Applicant CV single file field, and it must be 10 or less pages in length. (sbfunc is not run on Save Draft, so the record can be saved with Save Draft, if available)
function sbfunc(frm){
var aCV=parseInt("@Applicant CV.numofpages@");
   alert("You must upload a PDF of the Applicant CV");
   return false;
   alert("The Applicant CV must be less than 10 pages in length.");
   return false;

The same can be achieved with Submit Logic

@level1.Applicant CV.numofpages@>0

  • The number of files (PDF or otherwise) in a Multiple Files field can be evaluated using numoffiles.
function sbfunc(frm){
var supDocs=parseInt("@Supporting Documents.numoffiles@");
   alert("You are not permitted to include more than 10 supporting documents. Please remove at least "+(supDocs-10)+" files");
   return false;
return true;


  • If an uploaded PDF file is encrypted it will not be possible to attach it to a Web Page View using ssattach.
  • Attempting to attach an encrypted PDF will not prevent the Web Page View from being converted to PDF. The encrypted file will simply be excluded from the resulting PDF document.
  • Note: when inserting multiple PDFs into the centre of a Web Page View: If you are using the numofpages attribute to calculate the page location to insert a PDF into a Web Page View, any preceding documents that are excluded because they are encrypted will still be included in the page count so will disrupt the sequence of subsequent PDF insertions.

Single File Custom Field

  • For a PDF uploaded to a Single File field the following script will trigger an alert indicating that the file should be replaced. The alert will appear after the page is saved.
  • Note: It is not possible to trigger an alert as soon as the file is uploaded, only when the page reloads after the record is saved.

function onloadfunc(){
   if("@Applicant CV.[encrypted]@"=="Encrypted")
      alert("The PDF version of the applicant CV is encrypted and cannot be attached to the application. The file must be replaced with a PDF that does not have the 'Content Copying' restriction in place.");

Multiple Files Custom Field

  • PDFs stored in Multiple Files fields cannot be automatically evaluated for the encrypted attribute. The encrypted attribute can be included as a column on the list view by adding the following to the Extra Columns field on the Multiple Files custom field settings:
Pages,Is Encrypted::numofpages,encrypted
  • The multiple file field will then display as follows, and the user can visually ensure the files are not encrypted.

See Also