cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GabrielleJG
Regular Visitor

Add file properties only when file name contains 'Job Aid' or 'Learning' to an excel sheet

I had initially built this flow and it easily populated the excel sheet. However, now the flow would add any file that is created in the target files - not just the ones that include key strings/words. 


When I examined this, the conditions would return 

 

 

true

 

 

 

with any string, no matter the name, when compared with 'File name with extension' or 'Name'.


 


Now I am adding a trigger condition to the 'When a file is created or modified (properties only)' 

 

@contains(triggerBody()?['body/{Name}'],'Job Aid')

 

 

This is my fourth go with the contains line. But I know I am missing some context about how to use collections. 


Currently I am getting this error 'Cannot read properties of undefined (reading 'properties')' and though I have done some searching through, still cannot figure out how to sort this error. 

6 REPLIES 6
grantjenkins
Community Champion
Community Champion

For your trigger condition, try one of the following - both should work. The issue with yours is that you are getting the trigger body then getting the body again.

 

@contains(triggerBody()?['{Name}'],'Job Aid')

@contains(triggerOutputs()?['body/{Name}'],'Job Aid')

 

To check if it's equal to either Job Aid or Learning you would the following:

 

@OR(contains(triggerBody()?['{Name}'],'Job Aid'), contains(triggerBody()?['{Name}'],'Learning'))​

 

 



----------------------------------------------------------------------

If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.
GabrielleJG
Regular Visitor

Hi @grantjenkins ! Thank you for the quick reply

Tried both 

@contains(triggerBody()?['{Name}'],'Job Aid')

@contains(triggerOutputs()?['body/{Name}'],'Job Aid')

in the Trigger Conditions and still got the same error: 'Cannot read properties of undefined (reading 'properties')'

Not sure if this is an issue with other syntax with the output etc.

grantjenkins
Community Champion
Community Champion

Can you try the following to see if it works in your instance.

 

@OR(contains(triggerOutputs()['headers/x-ms-file-name'],'Job Aid'), contains(triggerOutputs()['headers/x-ms-file-name'],'Learning'))


----------------------------------------------------------------------

If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.

Thank you for coming back to this @grantjenkins!

Just tried it and seeing the same error: 'Cannot read properties of undefined (reading 'properties')'

Once again - it'll save however will not run

grantjenkins
Community Champion
Community Champion

Do you get that error message when you go to save the flow, or when it runs?

 

And is the error specifically on the trigger itself or another one of the actions you have?

 

It's interesting that on your trigger for the Array you have something slightly different to what I get.

 

//My trigger
@triggerOutputs()?['body/value']

//Your trigger
@triggerBody()?['value']

 

Have you tried deleting your trigger and adding a new one and see if that resolves the issue?



----------------------------------------------------------------------

If I've answered your question, please mark the post as Solved.

If you like my response, please consider giving it a Thumbs Up.

Hi @grantjenkins 

Okay sooooo I have updates. Went ahead and deleted my trigger then went to rebuild the trigger. Looks like it might be an issue with a loop later down.

Getting this error:
The execution of template action 'Apply_to_each_-_find,_delete_duplicates,_add' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['value']' is of type 'Null'. The result must be a valid array

Also when I went to rebuild the Array after using this Trigger Condition, the expected Trigger Array, didn't appear - nor did it allow me to edit the text field. 

//Trigger Condition
@contains(triggerOutputs()?['body/{Name}'],'Job Aid')

//Trigger Array
triggerOutputs()?['body/value']


Attached is the pic of the loop in question 


Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,530)