0

My logic contain when a file is created or modified in a folder (properties) trigger my SharePoint path is SharePoint/documents these two folders are same for all SharePoint files later onwards path will changes according to the files for suppose SharePoint/document/abc/calculations/country20230201.xlx here we we don't hardcode the year month and date so next path SharePoint/document/abc/formulas/country20220201

Can you show me the work flow of above one and on actions and trigger how will fill the details can you send these details

James
  • 21
  • 5

1 Answers1

0

You can use folder parameter in when a file is created or modified (properties only) trigger to pass multiple folders.

  • I have created logic app with trigger as shown below, enter image description here
  • Added condition in trigger to check if file is created or modified in folders calculations and formulas. Below is the expression written in trigger condition, @or(startsWith(triggerBody()['{Path}'], 'Shared Documents/abc/calculations/'),startsWith(triggerBody()['{Path}'], 'Shared Documents/abc/formulas/')) enter image description here
    enter image description here
  • If you want to add date dynamically to the file you need to follow below steps.'
  • Create a Get file properties action.
  • Next get the extension of the file with below expression in compose action. last(split(body('Get_file_properties')?'{FilenameWithExtension}'],'.')) enter image description here
  • Take another compose action and add current date at the end of file name with below expression, concat(concat(body('Get_file_properties')?'{Name}'],formatDateTime(utcNow(), 'yyyyMMdd')),concat('.',outputs('Compose_2')))
  • File name before adding date:enter image description here The output of logic app is, enter image description here
  • Using copy file action, you can copy file to destination folder.

Reference MS document

vijaya
  • 1,525
  • 1
  • 2
  • 6
  • Thank you vijaya is your solution is suitable if the file is uploaded in first the first path flow is excute successfully in logic but comming to second path i think it will failed for the second path flow insted failed will get pass i think will use condition but how we can implement that case – James Feb 27 '23 at 12:53
  • last(split(body('Get_file_properties')?'{FilenameWithExtension}'],'.')) is these expression is correct because If I give these expression compose action throws an error like invalid expression – James Mar 05 '23 at 07:13
  • The expression is correct, and you can see the logic App ran successful also. Once check are u giving it in compose as mentioned in solution. – vijaya Mar 06 '23 at 03:35