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?
Try to use 'Recognise Text' just to make sure it will do what you want.
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.
Hi @NR2023,
as far as I can understand, you are looking for this:
where:
outputs('Recognize_text_in_an_image_or_a_PDF_document')?['body/responsev2/predictionOutput/results'][0]?['lines']
and
item()?['text']
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:
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:
However, when I try it this is what I get:
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:
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.
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
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'.'.
I have created a demo flow
Here i have hardcoded sitecode in compose action like below
Now for json array purposes, i have intialized array
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 🙂
Michael E. Gernaey
179
Super User 2025 Season 1
David_MA
161
Super User 2025 Season 1
stampcoin
143