web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / find a substring in a ...
Power Automate
Unanswered

find a substring in a name field in an array of objects

(0) ShareShare
ReportReport
Posted on by 50

Hi,
I can't get my goal....I have several files inside a folder in onedrive busines and I used get files action to list them and after I used parse json action and finally converted in an array variable (array of objects) whose structure is:

 

{
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "Id": {
 "type": "string"
 },
 "Name": {
 "type": "string"
 },
 "NameNoExt": {
 "type": "string"
 },
 "DisplayName": {
 "type": "string"
 },
 "Path": {
 "type": "string"
 },
 "LastModified": {
 "type": "string"
 },
 "Size": {
 "type": "integer"
 },
 "MediaType": {
 "type": "string"
 },
 "IsFolder": {
 "type": "boolean"
 },
 "ETag": {
 "type": "string"
 },
 "LastModifiedBy": {
 "type": "string"
 },
 "FileLocator": {
 "type": "string"
 }
 },
 "required": [
 "Id",
 "Name",
 "NameNoExt",
 "DisplayName",
 "Path",
 "LastModified",
 "Size",
 "MediaType",
 "IsFolder",
 "ETag",
 "LastModifiedBy"
 ]
 }
}

 

 Then I would like to iterate throuh the output of the latest step (over my array variable) and check for each iteration if the name field of the current ojbect cointains a value of a compose action defined outiside the loop so that depeding on the result I can do some actions rather than other in case it doesn't match.
Example:
Suppose I have three files in an onedrive path:
file1_mode2.zip
file30_mart3.zip
dog_miller.zip
and my compose has value: miller
It means that at the third iteration by comparing the name parameter of my array (dog_miller.zip) with the compose value (miller) I should get true by using contains function, but I always get false.
Could someone help me out?
Thanks

Screenshot1.png
Categories:
I have the same question (0)
  • v-liwei-msft Profile Picture
    Microsoft Employee on at

     

    You don't need to use parse json.

    I have made a test for your reference:

    vliweimsft_0-1675239654012.png

     

    Best Regards,

    Levi

    Hi @AlexPowerApps 

  • AlexPowerApps Profile Picture
    50 on at

    Thanks for getting back, but I had already tried and even if  I use the containes function any iteration is false ,but the filename contains the value of compose.. I also used toUpper to make it case insensitive..but nothing
    Please see below:

    AlexPowerApps_0-1675246474915.png

     

  • AlexPowerApps Profile Picture
    50 on at

    As addendum, I attached these two screenshots: To show that any iteration is false

    I also tried to create two compose to see what values have...but contains function always gives false:

    AlexPowerApps_0-1675248727974.png

     

    Screenshot3.png
    Screenshot2.png
  • AlexPowerApps Profile Picture
    50 on at

    I also tried to use indexof function, but nothing changes...I get -1 even if there is part of string that I am looking for..

    AlexPowerApps_0-1675252635927.pngAlexPowerApps_1-1675252743878.pngAlexPowerApps_2-1675252781058.png

    Please any hint?

  • VictorIvanidze Profile Picture
    13,079 on at

    Hi @AlexPowerApps,

    instead of outputs('cognomeMod') try to use

     item()?['cognomeMod']

     

  • AlexPowerApps Profile Picture
    50 on at

    AlexPowerApps_0-1675265953597.png

    AlexPowerApps_1-1675265989036.png

    Nothing happens...cognomeMod is a compose action outside the loop, so why do you want to call it via item() function?
    Anyway, it seems very complicated to check a substring in a filename field of this array....

  • AlexPowerApps Profile Picture
    50 on at

     

    I also tried another function: encodeUriComponent , if I put a hard-code string it finds the index as expected, while if I put or variable or compose whose value is 'Sottole' returns -1....so the issue is in the variable or compose outside the loop is just like not to be a string....

    AlexPowerApps_1-1675269429259.png

     

  • AlexPowerApps Profile Picture
    50 on at

    I just reviewed the contains function and from my understanding, the second parameter must be a hard-coded string and not a variable or compose...Thus, I really don't know how to find in the Name parameter of an array of objects a substring based on a value of variable or compose action

  • VictorIvanidze Profile Picture
    13,079 on at

    Your understanding is wrong, sorry.

    Could you provide the output of compose action that contains cognomeMod?

  • AlexPowerApps Profile Picture
    50 on at

    Yes, you're right because I'm testing out of my loop by defining another compose with a substring that I know is included in my filename and then I use contains function putting as the first parameter a simple string (it would be my filename) and the second parameter compose action. With cognomeMode compose action I get false (that's not true) while with compose_2 action I correctly get true... Below the difference between two compose actions:

    AlexPowerApps_0-1675278090932.png

    Addendum after run the flow:

    AlexPowerApps_0-1675279836150.png

    AlexPowerApps_1-1675279859897.png

    As you can see, the output of both compose are equal but if I use the CognomeMod compose as a second parameter in the contains function returns false (wrongly )...am I getting crazy 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 58

#2
David_MA Profile Picture

David_MA 53 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 36 Most Valuable Professional

Last 30 days Overall leaderboard