0

I'm using power autometa so my trigger is when a file is created or based on my file path i was decided to give dynamic expression Shared Documents/new/Source/2023/Apr/Apr-jun/file.xlsx

enter image description here

how can I add expression on above image points out

I didn't saw any expression things on trigger option so Is it possible to give expression

Skin
  • 9,085
  • 2
  • 13
  • 29
Venu
  • 1
  • 1

1 Answers1

0

You could combine concat and utcNow functions to recreate that folder path value dynamically.

The yyyy format specifier is used to retrieve the current year in 4 digits (2023), the MMM format specifier is used to retrieve the abbreviated name of the current month (Apr).

With a startsWith contains function you can check the Folder Path (aka {Path}) property value of the trigger action outputs via a trigger condition expression. If that is true the flow will trigger. If it is false it won't trigger at all.

With the path examples you shared so far the contains should match on the highlighted part of each of the below paths:
Shared Documents/new/Source /2023/Apr/ Apr-jun/file.xlsx
Shared Documents/new/data country1 /2023/Apr/ file2.xlsx
Shared Documents/new/country 2 /2023/Apr/ file 3.xlsx
Shared Documents/new/country/pb/cost /2023/Apr/ 06-Apr/Apr-jun/source/files.xlsx

Add the below expression as a trigger condition in the settings of the trigger action (first action in the flow)

@contains(triggerOutputs()?['body/{Path}'], concat('/', utcNow('yyyy'), '/', utcNow('MMM'), '/'))

enter image description here

Expiscornovus
  • 1,222
  • 1
  • 3
  • 7
  • If I upload the file on that path power autometa did not trigger is there any problem in that solution – Venu Apr 05 '23 at 13:06
  • If you want to test that you could remove the expression from the trigger condition and add it to a compose action first. Add it in the compose without the @ character btw, `startsWith(triggerOutputs()?['body/{Path}'], concat('Shared Documents/new/Source/', utcNow('yyyy'), '/', utcNow('MMM')))` . This way you can trigger the flow and troubleshoot the expression before you use it in the trigger conditions setting. The outcome should be true. If it comes out as false, it means your Folder Path does not match. – Expiscornovus Apr 05 '23 at 13:21
  • I think these solutions will not work for my case because on my SharePoint there will be have n number of paths so if we given SharePoint address in trigger it will be trigger every time if the file are uploaded in tha SharePoint address so I want to trigger my power autometa only if the file is uploaded the exact path hope you can clear with my question – Venu Apr 05 '23 at 13:42
  • Can you clarify what is different in those other paths? Do those paths use a different naming convention. So not the shared documents/new/source/year/month format? If so, please share those paths as well. That would help to find a solution for you. And you could use or function in expressions to check those other paths as well. – Expiscornovus Apr 05 '23 at 14:02
  • There will will be have 20 to 30 paths will be there for same SharePoint address – Venu Apr 05 '23 at 14:38
  • Can you share examples of those variation paths? Just telling us the number of variation paths doesn't really help to determine if we can make it dynamic – Expiscornovus Apr 05 '23 at 18:19
  • Shared Documents/new/data/underq1/20223/Apr/file1.xlsx – Venu Apr 06 '23 at 01:48
  • Shared Documents/new/data country1/2023/Apr/file2.xlsx. Shared Documents/new/country 2/2023/Apr/file 3.xlsx. Like that there will be have 20 to 30 paths will be there – Venu Apr 06 '23 at 01:59
  • Thanks for sharing Looks like the common thing is that the paths always contains /yyyy/MMM/ Check for that with the trigger condition expression `@contains(triggerOutputs()?['body/{Path}'], concat('/', utcNow('yyyy'), '/', utcNow('MMM'), '/'))` – Expiscornovus Apr 06 '23 at 05:57
  • Soory I didn't understand your point – Venu Apr 06 '23 at 06:29
  • My path is Shared Documents/new/country/pb/cost/2023/Apr/06-Apr/Apr-jun/source/files.xlsx – Venu Apr 06 '23 at 06:33
  • With that last example that path should match and the expression result should be a true. Because /2023/Apr/ is in it. The concat function creates that same string value and checks with a contains function if the {Path} property from the trigger action contains this value. This should be reusable for other variations of paths as well, because they all have in common that the path contains /yyyy/MMM/. – Expiscornovus Apr 06 '23 at 08:45
  • Can I give the same expression in trigger settings or can mention my path on to that expression – Venu Apr 06 '23 at 09:26
  • You can add the last expression directly into the settings of the trigger action. No need to change anything in that expression. I have updated my proposed answer to show that new expression and also added a bit more context (references to the format specifier docs). – Expiscornovus Apr 06 '23 at 09:46
  • Can you please give me the updated expression – Venu Apr 06 '23 at 10:02
  • I have already shared it in the answer and in the comments, it should be there. To be clear, this is the updated expression I was referring to: `@contains(triggerOutputs()?['body/{Path}'], concat('/', utcNow('yyyy'), '/', utcNow('MMM'), '/'))` – Expiscornovus Apr 06 '23 at 10:20
  • If the file was uploaded in SharePoint Power autometa did not trigger if use above expression – Venu Apr 06 '23 at 10:43
  • In which of the paths are you uploading? And are you using the same trigger action? The When a new file is created (properties only) action? – Expiscornovus Apr 06 '23 at 11:00
  • Trigger is when a file is created or modified path is as if now shared documents/new/country/pb/cost/2023/Apr/06-Apr/Source/file.xlsx – Venu Apr 06 '23 at 11:08
  • That specific trigger action should also return a {Path} property. You have selected the Documents (aka Shared Documents) library in the Library Name dropdown and you have left the Folder field empty, correct? You are only using the trigger condition expression in the settings? I have tested this contains expression with both trigger actions in my dev and it should work properly. – Expiscornovus Apr 06 '23 at 11:31
  • You mean can I give Shared Documents/new/Country/pb/Cost in folder after then will give that expression in settings. Correct if we do like that end of the path there will be have Source folder what about these case – Venu Apr 06 '23 at 11:38
  • Thanks it's working how can we give Apr-June in utcNow format – Venu Apr 06 '23 at 11:52
  • Not all your folder paths use that subfolder, so I really don't understand why you want to check that as well. When you are going to include that additional check those paths which don't use that format will be excluded. Can you also tell me what the logic is behind that Apr-Jun folder format? Is it always one of these four Jan-Mar, Apr-Jun, Jul-Sep, Oct-Dec? And let's say your are using this flow in 4 weeks from now (when the date is 06th of May). On that date do you still want to check if the file is uploaded in a subfolder called Apr-Jun which is than located in the 2023/May/ ? – Expiscornovus Apr 06 '23 at 14:47