Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ConfiForms "File" field - attach uploaded files to newly created page

I've made a ConfiForm that creates a new page once submitted. There is a "File" field included in the form, and I would like the uploaded files to be attached to the page created after submission rather than the page hosting the form. I've tried everything with the IFTTT rules macro - the "create attachment" action will only create an attachment on the form's page, and "move attachment" only accepts a page ID for its destination page, which can't be used since the new page's ID isn't created until after submission. Any way to perform this seemingly simple task?

3 answers

See https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

And the "transform" function in particular which shows you how to get attachment IDs from a file field

 

[entry.myfile.asAttachments.transform(id)]

Hi Alex,

Im picking this up much later in the thread.

The case is this:

I have a form which has file upload fields, 3 of them to be exact.

Only one of these fields requires the attachments to be added onto a new page. The particular field is a "multiple" image field. E.g. user can upload multiple files to this field.

Once the user submits the form, I have 3 IFTTT rules, one creates a page to display the content that was submitted (individual page added per record submitted populated from the field data), the second should create a page and attach the images from the aforementioned field, the third IFTTT rule tracks the changes to the entries (OnModified).

 

ALL the IFTTT's fire, however, the second, which is supposed to attach the images to the page, I cannot understand from the links and answers provided, how exactly I attach an image to a page, if you could give me the [one.liner] that I'm looking for, I shall happily be on my way :)

So, you create a page for the attachments dynamically? In the second IFTTT?

You need to know the page id of this page you create - this can be accessed in the IFTTT result velocity variable

${iftttResult_YOUR_IFTTT_CREATING_PAGE.id}

holdsit, assuming the ifttt result is called YOUR_IFTTT_CREATING_PAGE

And you will need another IFTTT to run after the one above to MOVE the attachments to newly created page

 

Simplified example to illustrate the concept in storage format

<ac:structured-macro ac:macro-id="30d5495b-6308-49a4-9a0b-e5038e856bbd" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="4074a4db-d7ef-4840-8f39-de4b26f1329e" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="9c49277c-632c-4a4e-ace2-9f57dbbb439e" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">title</ac:parameter>
<ac:parameter ac:name="fieldLabel">Title</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5c9dfc46-6864-435f-b202-8d63be58c9f0" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">f1</ac:parameter>
<ac:parameter ac:name="fieldLabel">my File</ac:parameter>
<ac:parameter ac:name="type">file</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="08469283-3a21-4cc8-8fc9-df22704d7cc8" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">pageCreated</ac:parameter>
<ac:parameter ac:name="fieldLabel">Created page</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="5fbe6823-0f91-4bac-86d7-232e14915ff1" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create Page</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">[entry.id] - [entry.title]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="f8fdcef9-14ca-4c53-80c4-d37127885cb6" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;pageCreated=${iftttResult_0.id}</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="c832057f-70ab-4e44-949d-5d391be048c3" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Move Attachment</ac:parameter>
<ac:parameter ac:name="extras">[entry.pageCreated.id]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">[entry.f1.asAttachments.transform(id).asList]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>

Ah ha! The particular line I think Im missing is regarding the action "OnCreated" to "Move Attachments" I will respond here shortly when I have figured out how to adapt your code to mine.

 

By the sounds of it, you grasp a good understanding of what I am trying to do.

By uploading a particular program it should be Id attachment so that it will not be corrupted to the others.

@Alex Medved _ConfiForms_

It seems to be working just fine now, thank you very much for your assistance. I'm sure your answer will help others in the future if they stumble across this post!

Awesome, @Dean McGinn

Please accept as answer and vote up :-)

Some people scan the answers diagonally or look for the first one... so it would be easier for them to jump into the right thread

Unfortunately I can only vote on this, but have done that all the same. I'm not the OP of this question I'm afraid. Would you like me to create a seperate thread and then we can have fresh copy there?

@Alex Medved _ConfiForms_

 

Hi Alex, the example you gave me gave me a point in the right direction, however, can you tell me how to do the same thing, except, this time, can you show me how I get a "REAL LINK" not the "viewpage.action?page=<id>"

 

Also, is Confiforms supported in Scroll Viewport (K15T)? 

Just wondering as I found there is a huge bug when trying to edit the form from within a viewport.

Like Karina Green likes this

Your field "pageCreated" is a bridge to actual rich object of https://docs.atlassian.com/atlassian-confluence/6.3.0/com/atlassian/confluence/pages/AbstractPage.html

 

See (get)urlPath method for example

As for issues with a 3rd party plugin you have mentioned, please do contact us via support form: https://wiki.vertuna.com/display/VERTUNA/Support+Request+Form and let's work together on the "huge bug" you have discovered

Please note that we cannot guarantee that our plugin works with every other 3rd party plugin out there, but we try to do our best

@Alex Medved _ConfiForms_ I was following these instructions and it worked out great. When I add another file upload field to my form and add another ifttt to move this attachment also to the page which is created by the form, it shows an error message after saving the form entries. it says "attachment id must be numeric". Is there a way to move several files uploaded in the form to the page that is created by the form? :) 

Yes, you can.

The error just tells you that you have set incorrectly the attachment id to move. So it is a configuration error and not a limitation in ConfiForms

Do you check if the attachment/file was actually uploaded by user, I mean in the IFTTT condition that attempts to move the attachment - do you have something like

!yourattachmentfield:[empty]

(if your field for attachment is called "yourattachmentfield")

Got it now. As the attachment ids i used 
- entry.UPLOADFIELDNAME.asAttachments.transform(id)]

but i did had the same field name by copy & paste in before, sorted out now. Thanks for your quick reply

Hello @Alex Medved _ConfiForms_ - one more question regarding this:

The upload field does initially allow to select and upload multiple files. This causes a problem with above mentioned procedure. Is it possible to 

- set the upload file field to allow the selection of one file only? 

or
- perform the transform id for several files uploaded in one field to move them? 

Thanks as always. 

You need to prepare a list of IDs

Just do the following and that works for single/multiple files

[entry.UPLOADFIELDNAME.asAttachments.transform(id).asList]

 Another option is to validate the number of files uploaded and raise an error it there is more than 1

[entry.UPLOADFIELDNAME.asAttachments.asSize]
or
[entry.UPLOADFIELDNAME.asAttachments.asLength]
or
[entry.UPLOADFIELDNAME.asAttachments.asCount]

Hi Alex - 

The questioner above mentions that the 'upload field' initially allows the selection and uploading of multiple files.  Perhaps I am using the wrong type of upload field because I cannot get multiple files to upload to the field I've created on my form, using field type of File - Upload files/images.  For this field, I can choose Browse only once, because the second time, the first file searched for and selected just gets replaced.

Thanks - 

Steve

Steve, 

the field supports selecting multiple files at once. Not selecting one and then selecting another, but selecting multiple files at once.

Also, you can attach more files after you have created a record (just edit the record and you will be able to attach more files to the field in ConfiForms)

Hi Alex -

Thanks for this information, and I have what I need to forge ahead with the rest!

Steve 

We try to keep this page up to date - the differences between ConfiForms server and cloud

And basically working on feature parity as much as we can, but the matrix is still very "red"...

I would like to add a question here @imedv 
Though I managed to move attached files to a newly created page as described above, I am struggling with just getting the attachment id displayed in a view. 

I have a table view in which I would like to see the attachment id instead of a thumbnail or preview. What do I need to enter in the form field macro within the view? 

Field name is 'file1'.
I tried 

  • file1.asAttachments.transform(id) >> will show a thumbnail in the view
  • file1.asAttachments.id >> will show a thumbnail in the view
  • file1.asAttachment.id >> will show a thumbnail in the view

Why cannot you use the ConfiForms Field macro?

But if you insist on using [entry.field_name] references then you need to construct the <img> url yourself

<img src="[entry.file1.asAttachment.downloadPath]"></img>

Alex

@Alex Medved _ConfiForms_ thanks for your reply. Maybe I was not clear, I would love to use the Field Macro and tried to with all 3 above mentioned attempts for field name in the macro. What do I need to set under field name in the ConfiForms Field macro to get the Attachment ID here? Thanks again for your help... 

file1

nothing else... name of the field

But this will display the attachment itself (thumbnail).
I want to get the Attachment ID in my view

You want to display an attachment ID!?

file1.asAttachment.id should be the correct expression

Alex

I tried this, as stated above it will give me a thumbnail for images and a link for other documents... 

Probably I misunderstand your comments.. but this is what I understand and did - http://recordit.co/slTGWfLGLr 

Do you mean something else?

Alex

Thanks @Alex Medved _ConfiForms_ I meant exactly this and did exactly the same, but with a different result. I do not see the Attachment ID in my view, but the attachment preview or link, I have no clue why... 

screen1.png

Just yo make sure… there is no space after the dot (.) in the file1 (expression)?

No spaces at all. 

We do not have out attachments in the DB but in the file system, but I guess this does not matter, transforming in IFTTT for moving attachments was working fine

I have no clue, sorry... it works as expected when I test it

Hi, were you able to do this? 
I have the same issue. :)

Yes, the solution is similar to this tutorial:

https://wiki.vertuna.com/display/CONFIFORMS/Using+excel+macro+with+pages+created+by+ConfiForms

But just replace the Excel macro with whichever file view macro you need!

This doesn't attach files to the page like the question asks. 

See my answer and use ConfiForms IFTTT macro that moves attachment to a desired page with the help of "asAttachments.transform(id)" function

Is there a place where I can find all the appropriate properties that an "attachment" (or any other field types) can have that the transform function can get (in addition to "id")?

Yes, that page does not list the members, only the getXXX methods. I was trying to get the attachment names and with my test (save the result to a form field), there's no difference between [entry.FileField.asAttachments], [entry.FileField.asAttachments.FileName] and [entry.FileField.asAttachments.transform(FileName)]. All of these gave me the following:

Attachment: 1.gif v.1 (64062114) JCZ Attachment: 2.gif v.1 (64062115) JCZ

[entry.FileField.FileName.toArray]

@Alex Medved _ConfiForms_ In the above I am not able to follow how you are setting the attachment ID to pull dynamically as a numeric value.  I am also getting the error "Attachment ID was given in a wrong format (must be numeric)"  How do I appropriately set the parameter for the attachment ID.  In this case my field is "attachment".  

On the created page I am getting text output - 

Attachment: draft requirements 091819.docx v.1 (93862221) userid

What I want to appear there is the actual file attached to the page in some way.

How do you reference the file field in ConfiForms? Via ConfiForms Field macro or via reference to the raw value like [entry.field_name]?

 

Attachment ID is what you see in (93862221)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

330 views 3 14
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you