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 / Filtering Array with P...
Power Automate
Unanswered

Filtering Array with Partial Text Value

(0) ShareShare
ReportReport
Posted on by 28

I am trying to build a flow that allows the user to upload a PDF and then it splits the PDF based on a site code. To accomplish this I am utilising the Adobe API and this guide. However I can't get it to work for my use case.

 

The issue I have is that the only field I can filter on begins with a random word e.g. HR/IT/Finance followed by the site code. In my flow I have a 'Filter Array' that filters 'Text' containing '(Site Code)' however the flow won't accept it and spits on this error message.

 

failed: 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

 

Does anyone have any ideas or any ideas on how I can split a PDF based on a value contained on the page?

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    @NR2023 

     

    I have created a demo flow

    Nived_Nambiar_0-1679941102620.png

     

    Here i have hardcoded sitecode in compose action like below

    Nived_Nambiar_1-1679941128476.png

     

    Now for json array purposes, i have intialized array 

    Nived_Nambiar_2-1679941157650.png

     

    Here my aim is to filter the B field with values starting either with IT{Sitecode} or HR{Sitecode} or Finance{Sitecode}

    So I have used a filter array with or condition like below

    or(startsWith(item()?['B'],concat('IT',outputs('SiteCode'))),or(startsWith(item()?['B'],concat('HR',outputs('SiteCode'))),startsWith(item()?['B'],concat('Finance',outputs('SiteCode')))))

     

    (Here I am checking whether the b field value is starting with IT{Sitecode} or b field value is starting with HR{Sitecode} or b field value is starting with Finance{Sitecode} using OR condition)

     

    Hope this help you 

    Mark it as solution if it helps 🙂

     

  • NR2023 Profile Picture
    28 on at

    Hi,

     

    Thank you for your response. I've tried to modify the code using the example provided but I get the exact same error.

     

    ' failed: 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @NR2023 

     

    But we are not using contains function anywhere in the expression right ?

     

    Only i have used startswith there ?

     

    Could you check ur expression once again or if possible share the expression which you have written 

  • NR2023 Profile Picture
    28 on at

    Hi Nived,

     

    Maybe it would help if I show you what flow I'm using. You can download the flow from here 

     

    Here is the Parse JSON bit:

    1.png

     

    In my flow example, I am using this PDF file - Download here 

     

    Now imagine in my scenario, that this PDF contained all the invoices for the company and it had several sheets per supplier. I want to be able to filter on text so that all invoices by company marked 'Halliby' are exported into a separate pdf file.

     

    For this I want to try and do the following:

     

    2.png

     

    However, when I try it this is what I get:

     

    3.png

     

    The execution of template action 'searchArray' failed: The evaluation of 'query' action 'where' expression '@contains(item()?['Text'], 'Halliby')' failed: 'The template language function 'contains' expects its first argument 'collection' to be a dictionary (object), an array or a string. The provided value is of type 'Null'.'.

     

    When I inspect the output of the previous action, I can see that the field is exported from the PDF correctly:

     

    4.png

     

    So that's from the example scenario. I'm basically trying to do similar except our site codes are in the format of Finance (Hero)

     

    where (Hero) is our site code. 

  • VictorIvanidze Profile Picture
    13,073 on at
  • VictorIvanidze Profile Picture
    13,073 on at

    Hi @NR2023,

     as far as I can understand, you are looking for this:

    VictorIvanidze_0-1680082178050.png

    where:

    outputs('Recognize_text_in_an_image_or_a_PDF_document')?['body/responsev2/predictionOutput/results'][0]?['lines']

     and

    item()?['text']
  • VictorIvanidze Profile Picture
    13,073 on at

    Hi @NR2023,

    any comments? 

  • NR2023 Profile Picture
    28 on at

    Hi Victor,

     

    Sorry I'm not seeing how I can use that code sample in my flow? I'm not using the 'Recognise Text' function I am using the 'Adobe Extract PDF Content' option.

     

    6.png

  • VictorIvanidze Profile Picture
    13,073 on at

    Try to use 'Recognise Text' just to make sure it will do what you want.

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard