Question

How to transfer existing file into the "file attachement" control?

  • 9 October 2020
  • 5 replies
  • 117 views

Badge +6

Hello,

I have the following problem:

we have a process where the user can upload files as an attachment. This attachments ar saved as attachment to a SharePoint list item.

These attachments are later on in the process attached to an email. If the email exceeds a given size, it cannot be send (email size too big)

Now I want to implement a check, that the process cannot be started if the sum of all attachments exceeds a given size.

I found no way to get the file size of the attachments. I found a way to get the file size with JScript, when the user uploads the file (it is visible in the file attachment control on the view)

So I have the possibility to get the single sizes and I can make a sum and save the total size to the list item (this is no problem up to here)

 

But the users are able to “delete” existing file attachments and I found now way to find the file size of the deleted files to substract it from my total file size…

 

I tried to put the file into the “file attachment controll” but I found no way to do this. Is this even possible? If I manage to do this in a rule I can read the file size with JScript again and substract it…

 

Any ideas?

 

With the SP API there is a way to get the file size of any attachment file like this:

{site_url}/_api/web/getfilebyserverrelativeurl('/path/to/List/Attachments/{ListItemID}/{filename}')/Length

 

But I found no way to “read” this into K2 (either a form or in a process?)

 

regards,

Johann


5 replies

Badge +6

no one any idea?

Userlevel 1
Badge +4

no one any idea?

Please check this out

 

https://www.datalytyx.com/discover-the-size-of-your-sharepoint-documents-using-k2-smartobject/

Userlevel 1
Badge +4

another workaround you can try it out is by calculating the total length of stringbase64 of the attachments.

 

The rough estimation stringbase64 will be 125% to 135% of original size because expansion and K2 xml structure.

 

Please check this out.

https://help.k2.com/onlinehelp/k2five/userguide/current/default.htm#LegacyDesigntools/K2_for_VisualStudio_K2_Studio/4.Workflow/InlineFunctions/FB_Files.htm%3FTocPath%3DCreate%7CLegacy%2520Design%2520Tools%7CK2%2520for%2520Visual%2520Studio%7CWorkflow%7CObject%2520Browser%7CFunction%2520Browser%7C_____6

Badge +6

no one any idea?

Please check this out

 

https://www.datalytyx.com/discover-the-size-of-your-sharepoint-documents-using-k2-smartobject/

I almost thought that this might be the solution but my problem is that we have “attachments to a list item” instead of files in a library. So the File Size column is not there...

Badge +6

another workaround you can try it out is by calculating the total length of stringbase64 of the attachments.

 

The rough estimation stringbase64 will be 125% to 135% of original size because expansion and K2 xml structure.

 

Please check this out.

https://help.k2.com/onlinehelp/k2five/userguide/current/default.htm#LegacyDesigntools/K2_for_VisualStudio_K2_Studio/4.Workflow/InlineFunctions/FB_Files.htm%3FTocPath%3DCreate%7CLegacy%2520Design%2520Tools%7CK2%2520for%2520Visual%2520Studio%7CWorkflow%7CObject%2520Browser%7CFunction%2520Browser%7C_____6

is it possible to get the stringbase64 from the SP Attachment SMO (the file property) in the form rules?

Because this property is empty for me...

Reply