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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to check item exis...
Power Automate
Unanswered

How to check item exists in Array of Objects using "contains" expression?

(0) ShareShare
ReportReport
Posted on by 316

Hi,

contains   - this expression in array can tell if element exists or not,(true/false)

for a simple array of number it works just as expected

PabloRoldan_0-1641199183342.png

Expression: contains(variables('ArrayNumber'),5)

PabloRoldan_1-1641199193813.png

result True

 

BUT

 

How to know if object exists in array using contains?

PabloRoldan_2-1641199293283.png

 

using contains how can I know if this arrays contains id = 2 o id = 3

 

Categories:
I have the same question (0)
  • jinivthakkar Profile Picture
    4,187 on at

    @PabloRoldan please see if this helps, I think it is a similar usecase

     

    https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-validate-if-a-item-exists-in-array-of-objects/td-p/1212407

     

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

    If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

  • tapan Profile Picture
    Microsoft Employee on at

    one naïve solution, I can think of is you can convert the object into JSON and iterate over the records in json to check if the value exist in array or not

  • mahoneypat Profile Picture
    1,720 on at

    You can add a Filter step with your PeopleArray as input where the expression below equals true, and the check if the length() of the array from the Filter step is >0.

     

    contains(createArray(2,3), item()?['id'])

     

    Pat

  • Pablo Roldan Profile Picture
    316 on at

    Hi, With contains function then...

    contains('<collection>', '<value>')

    can I pass a object to that function and validate if exist or not?

     

     

     

     

     

    [
    {
    "id":1,
    "nombre":"Kate"
    },
    {
    "id":2,
    "nombre":"Ana"
    }
    ] 

     

     

     

     

    in a compose node I set this expression

    PabloRoldan_0-1641945949548.png

     

    contains(variables('ArrayFromAbove'), 'HOW TO PLACE THE OBJECT HERE LIKE ID = 2 , I DON'T KNOW WHAT TO PLACE HERE?')

     

     

    if it's not possible then i think I will use more action nodes like filter or iterate as you suggests

    Thanks.

  • yevreeva Profile Picture
    33 on at

    After struggling to find an answer to this exact question, and nearly giving up I was able to come up with a solution that's so simple, it hurts :). Simply envelop your variable (or your array) in a "string" (thus converting it to a string) to be able to search all of its content. For your example it would be:

    contains(string(variables('ArrayNumber')),'5')

     

    In my case, I had the following output from a SharePoint choice column that I was checking if a value exists:

    [{"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference","Id":0,"Value":"NORTH"},{"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference","Id":1,"Value":"SOUTH"}]

     

    I used following formula to check:

    contains(string(items('Apply_to_each')?['Platform'], 'NORTH')

    which returned "true" as expected.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard