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?

2 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.

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

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]

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,477 views 6 6
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you