Hi experts
I need some help with an issue. I have a form with a field for picking files/attachments, type File/Attachment. Let's call this field myFiles
In this file, I can have 1,2,....., n files attached. I am triggering an IFTTT onModified that sends an Email with the files of that record. My problem is when the files are to heavy as to be sent by email. That's why I would like to know how to get the total size of all the files of one record, to trigger the email with the files in case they're less than 20MB in total and another different email without the files attached, including a link to a local resource in that case.
Is that possible? I think I should use a condition with something like:
myFiles.asAttachments.virtualfunctionhere:<SizeLimit (20MB) in this case
but I can't find the right one.
Could you help me with this? Thank you.
Hi
asAttachment transforms to Attachment object which you can query for properties
And fileSize is the one you are looking for (this answer is valid for server/dc and is different for cloud)
myFiles.asAttachment.fileSize
on cloud it is
myFiles.asAttachment.extensions.fileSize
as per structure provided by REST API - https://developer.atlassian.com/cloud/confluence/rest/api-group-content/#api-wiki-rest-api-content-id-get
Alex
Hi Alex
Thank you for such a quick response.
I have applied it this way
myFiles.asAttachments.extensions.fileSize
and the result is as follows:
242593 438073 588238
The result that I want to get is the addition of those three values.
What modification should I introduce in my sintaxis to get the total?
Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, that is because if you look more carefully then the function I use is "asAttachment"
Not "asAttachments" - which is rather different thing - https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I know the difference. If I use asAttachment, it returns only the size of the first file uploaded, replicating exactly as you told. Then I thought of applying it to asAttachments, and the result was as I wrote before.
What should I do then to get what I need? Perhaps adding to the sentence another virtual function to add up all the values?
Sorry to bother you and thank you for your time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you know the difference then you should understand that what you do is not correct
To calculate the size of the all attachments associate with a field you may try to do something like
id.evaluateFormula([entry.myFiles.asAttachments.transform(extensions.fileSize).join(+)])
If you want to use an expression like that in filters then there is a trick to know...
id.evaluateFormula([entry._func.asEntryRef(entry.myFiles.asAttachments.transform(extensions.fileSize).join(+))]):>20971520
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, Alex. That worked perfectly. I have applied the expression in a filter an works fine.
Of course my approach was not correct. That is precisely the reason why I ask here looking for your expertise.
Thank you for everything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are very welcome. This is somewhat a "tribal knowledge" we need to document and explain better.
There is always a place for a better documentation - not doubt here
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.