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

Community site session details

Session Id : XjNK1hiuzbnYXcIUtdX3+K
Power Automate - Building Flows
Unanswered

Filtering Array with Partial Text Value

Like (0) ShareShare
ReportReport
Posted on 27 Mar 2023 17:46:43 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?

  • VictorIvanidze Profile Picture
    12,538 on 29 Mar 2023 at 16:30:59
    Re: Filtering Array with Partial Text Value

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

  • NR2023 Profile Picture
    28 on 29 Mar 2023 at 16:19:06
    Re: Filtering Array with Partial Text Value

    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
    12,538 on 29 Mar 2023 at 12:52:37
    Re: Filtering Array with Partial Text Value

    Hi @NR2023,

    any comments? 

  • VictorIvanidze Profile Picture
    12,538 on 29 Mar 2023 at 09:32:27
    Re: Filtering Array with Partial Text Value

    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
    12,538 on 28 Mar 2023 at 18:57:38
  • NR2023 Profile Picture
    28 on 28 Mar 2023 at 16:24:00
    Re: Filtering Array with Partial Text Value

    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. 

  • Nived_Nambiar Profile Picture
    17,954 Super User 2025 Season 2 on 28 Mar 2023 at 16:04:21
    Re: Filtering Array with Partial Text Value

    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 28 Mar 2023 at 15:57:39
    Re: Filtering Array with Partial Text Value

    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
    17,954 Super User 2025 Season 2 on 27 Mar 2023 at 18:22:56
    Re: Filtering Array with Partial Text Value

    @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 🙂

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete