Skip to main content
Nintex Community Menu Bar

Hi,

 

Is there a way to rename the attachment in k2 smart form?

I need to rename the file by adding a sequence number at the end of the file for the same filename so as not to overwrite the existing file and for history purposes.

1st File Name: SiteLocation.pdf

2nd: SiteLocation-01.pdf

3rd: SiteLocation-02.pdf

 

Thanks

Dabuskol

 

Hi,



 



Have you already uploaded the file into your database, or you have just attached the file to the file attachment control?



 



If you have only attached the file to the file attachment control, you can just delete the file in the attachment control, rename your file and attach it again.



 



If you have already saved the file into your database, then you will need to modify the records in your database.


I have two scenario of attachments
1st is generated by the application and 2nd user attachment.

My solution.
1st: To rename is to re-generate the attachment since it's from the application.
2nd: Like what you've mentioned to rename the file from the file system after saving the new file into my database.

I thought I could find an out of the box rename filename object from K2 unfortunately, K2 doesn't have.

Really appreciate your time to check my inquiry.

There is no out of the box method in K2 to rename the files.



 



If you have already saved your file into your database, then the only way to rename them is to update the record for that file on your database. For example, when you save a file into your database, the file itself is saved as a XML value that looks something like this:



 



<file>



  <name>Filename.pdf</name>



  <content>...</content>



</file>



 



You can rename the file by changing the file name within that XML value without touching the content value. When the SmartObject retrieves that file, it will use the updated file name.


You can use a SmartBox that stores down the file content. Ensure that the SmartBox creates a Reference.

The FileContent in the reference returned should have the FileName as well as FileContent.

If you were setting the attachment as part of the email, drag the Get File From Content function from the Functions list under the File category.

In the Filename field, enter the filename of your choice including the extension (i.e .pdf), in the FileContent field, drag the FileContent from the Reference.

 

The result would ensure that the file generated as an attachment uses the Filename passed into the Get File From Content function.

 

Hope this helps.

 


Reply