Rename File/Image attachments

Matthew Fulton April 7, 2021

I have a form that requires the attachments submitted with the confiform be named with specific naming convention. There are two problems that I am having; first, how to access the attachment file name from the confiform macros; second how to change the names of multiple attachments. 

My first thought was to use a IFTTT onCreated rule, but that there is only delete or copy attachment. I thought if I could copy the attachments to a page and use an onModified IFTTT rule I could change the name that way. Neither approach has proven to work beyond the copy of attachments to a new page. 

Users can upload docs to the form and the form needs to transform the doc:

example.pdf to asAttachment.displayTitle=[entry.my_Field]_[entry.my_Field1]_[entry.my_Field2][entry.my_Field3][entry.my_Field4]_BU[entry.asAttachment(0)index#]_[entry.my_Field5]_[entry._now.formatDate(yyyyMMdd)]

WTC000000_3333_AD22221111_BU(1-#)_$250_20210407

The BU(#) just needs to be the index number for the attachment. 

Is this operation even possible with the ConfiForm toolset?

1 answer

0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2021

You can use asAttachment function to establish a bridge to Attachment object that can be queried for any property it has, including the "displayTitle" - https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions 

 

Renaming attachments is not currently supported by ConfiForms natively

The only option you have at the moment is to set up a web service request and use something like https://docs.atlassian.com/ConfluenceServer/rest/7.11.2/#api/content/{id}/child/attachment-update 

Alex

vidourem July 9, 2021

Hello @Alex Medved _ConfiForms_ 

I need to copy an attachment to a created page and rename the file name. No problem creating the page and attaching the file, however I can't use the API for security reasons. When I rename the file manually using the properties of the attachment it changes the "form page" field of the macros of the created page by doubling the name of the space. example: "space: space: page" the macros cannot work without manually modifying the "page of the form" field.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2021

Hi

Is this related to ConfiForms in any way? Could you be more specific?

Thanks

Alex

vidourem July 9, 2021

Re @Alex Medved _ConfiForms_ 

It is in connection with Confiforms. I use an ifttt macro to create a page with a tableview macro inside and then use another ifttt macro to copy an attachment to the created page. It works very well.

However when I rename the attachment with the Attachments Properties ability of Confluence it changes the link to the Confiforms form page of the tableview macro by doubling the name of the Confluence space.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2021

Could you help me to understand how to reproduce this?

Where does it "double" the space name? Any screenshot? 

vidourem July 13, 2021

It is the pageTitle attribute which is modified following the renaming of the file. No problem as long as you don't change the file name.

The attachment was copied after it was appended to a form with the ConfiForms Form Field Definition macro with the Field type = File / attachment attribute.

I will try to add the attachment to the form without using this macro, I have a feeling that might work. I will keep you informed.

pageTitle-twice.PNGmacro-TableView.png

vidourem July 13, 2021

I found a workaround, I added a text field named "pageForm" valued with the name of the page where the form is located. Then I use [entry.pageForm] in pageTitle of the TableView macro included in the body of the ifttt macro that creates the page. I don't know why but this way the problem goes away.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events