question

ErshadNozari-6158 avatar image
0 Votes"
ErshadNozari-6158 asked JayaC-MSFT commented

Logic Apps SharePoint Connector - Move file with new file name

We have a integration requirement to move files from one folder to another in SharePoint Online. The new file name in the destination folder needs to be suffixed with the current datetime. For instance, if the source filename is Myfile.csv, it should be moved with the new name Myfile_2021-04-15T15:39:23.csv to the destination folder.

Using the Logic App SharePoint Move file action, I haven't been able to achieve this
88183-image.png

If another file is already there is an enum and I'm unable to provide a custom expression for it. Further, with this option files are only renamed if there's a file with the same name already existing in the destination folder. Whereas our requirement is to attach datetime to all files that are being transferred, independent whether the file already exist in the destination folder or not.

How can I best achieve this?

Thanks in advance for any assistance.


azure-logic-apps
image.png (44.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JayaC-MSFT avatar image
0 Votes"
JayaC-MSFT answered JayaC-MSFT commented
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @JayaC-MSFT, thanks for response. Yes I need to do something similar, but in SharePoint. The Move file action doesn’t seem to allow for this, or am I missing something? Cheers

0 Votes 0 ·

Hello @ErshadNozari-6158, did you try to create the expression for that. I tried the concat function as shown in the sample-link I shared

90121-image.png


It will reflect the expression value :

90131-image.png


0 Votes 0 ·
image.png (118.4 KiB)
image.png (22.7 KiB)

Hello @JayaC-MSFT, thanks for response. I did try Expression bud it did not work for me. This seems promising though, I’ll have a go at it again. Many thanks

0 Votes 0 ·

Hi @JayaC-MSFT, are you able to shoe me what your concat expression look like, please?

0 Votes 0 ·

Hello @ErshadNozari-6158, I have tried

  concat(body('Create_file')?['Name'],string(formDataValue(utcNow(),'yyyyMMdd')),'csv')





0 Votes 0 ·

Hi @JayaC-MSFT, are you using the Create File action? In my solution I'm using Move File action
90261-image.png


My concat expression is concat(triggerOutputs()['headers']['x-ms-file-name'], '20210422T162226') where triggerOutputs()['headers']['x-ms-file-name'] returns the original filename, and this fails for me with the following error message
"Failed to verify the existence of source object at 'https://...../fiename20210422T162226.csv' due to error 'The system cannot find the file specified."

This make sense as there is no file with that name to be moved from the original location, so I'm not sure how your expression can possibly work if you are using the Move File action?

0 Votes 0 ·
image.png (20.2 KiB)
Show more comments