Total size of a document array

Our current code is throwing an error while finding the total size of the document array 

 

 

local!docSizeList: if( rule!APN_isEmpty( local!items ),

{},

apply( a!fileUploadField_17r1( value: _ ),

local!items.document

).uploadedDocumentSize ),

 

Do you recommend any other way to find the total size of a document array ?

 

 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi Ashok, It is while uploading documents .. i totally agree with you .. i need to calculate the size of the "item" array within the upload page . is there any way i can achieve this ?
  • Hey Ramanan, if ur env is 17.2 and above version, then a!fileUpload() function allows you to access the metadata directly. Please refer to the link below:
    docs.appian.com/.../File_Upload_Component.html
    If ur env is below 17.2 then u might req to tweek a bit. Let us know which Appian version is ur environment in
  • It is possible to use the fileUploadField to gather certain properties of just-uploaded files, though I would note that this is officially unsupported functionality and therefore might change between Appian versions with no warning or explanation.  I also need to note that you're apparently using the 17.1 version of a!fileUploadField, which accesses only an abbreviated text version of the file size, i.e. "2kb" or "2MB".  In later versions it's possible to get the file size in bytes from each uploaded file.

    If you want to proceed with the unsupported functionality, I have found some success using the following expression rule which I developed (for versions >=17.3)

    /* GLBL_getTempUploadedFileProperties */
    /* by: mike schmitt */
    if(
     rule!APN_isBlank(ri!document),
     
     {
       fullName: null(),
       name: null(),
       ext: null(),
       size: tointeger(null())
     },
    
     with(
       
       local!value: a!fileUploadField(value: ri!document, fileNames: fv!file),
    
       local!fileDetails: tostring(local!value.contents.value.filename),
       
       local!fileName: extract(local!fileDetails, "[name=", ", extension" )[1],
       local!fileExt: extract(local!fileDetails, "extension=", ", size")[1],
       local!fileSize: tointeger(extract(local!fileDetails, "size=", "]")[1]),
       {
         fullName: local!fileName & if(rule!APN_isBlank(local!fileExt), "", "." & local!fileExt),
         name: local!fileName,
         ext: local!fileExt,
         size: local!fileSize
       }
     )
    )

    This rule returns a dictionary consisting of fullName (name & extension), name, extension, and size (bytes).  I highly suggest that if you use functionality like this, you at least keep it compartmentalized in as few places as possible (like one expression rule) so that if/when future updates change the way things work, the rule can be adjusted as needed or deprecated if Appian ever sees fit to allow us to do this via supported functionality (such as allowing us to access the fv! properties in the saveInto parameter of the a!fileUploadField, hint hint).

    Please let me know if you have any questions.