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 / How to identify pdf do...
Power Automate
Unanswered

How to identify pdf doc did not contain data in a flow?

(0) ShareShare
ReportReport
Posted on by

Hi 

this question is an extension of Saving PDF attachments with customise name to Shar... - Power Platform Community (microsoft.com)

 

Is there a way to get the flow to detect if the pdf document contains data?

If contain data:

name of the document would be "File name_lastModifiedDateTime.pdf"

 

If did not contain data:

name of the document would be "File name_lastModifiedDateTimex.pdf"

for example:

File name_24-05-12x.pdf (with a x behind to indicate that the document did not contain data)

 

How to know if it did not contain data:

to search for the phrase in the document: "No records in query report."

 

 

Categories:
  • takolota1 Profile Picture
    4,980 Moderator on at

    @memento 

     

    You could OCR the PDF text & then check for that phrase or you could use a 3rd party service like Cloudmersive to check for key words in a PDF.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @memento 

     

    In addition to what @takolota  said, there are some Third party actions which could help to get pdf content like Encodian , or if you have AI Builder access- you could use its actions to extract data from pdf document as well 🙂

     

    Also, if you try via Power Automate Desktop, there is an action to get data from pdf document 🙂

     

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • memento Profile Picture
    on at

    Hi all,

     

    How can the above external program integrate within the automated flow? 

    because one need to check:

    if ""No records in query report." does not exist, then continue as per normal.

    if "No records in query report." then place the x behind. 

     

    memento_0-1715661089322.png

     

    Anyone has encountered similar situation before?

     

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @memento 

     

    screenshot which you have shared is of flow which creates the pdf file out of attachemnts and u want those attachments validation whether they have any data or not correct ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • memento Profile Picture
    on at

    Yes so depending if they have data or not then name the file accordingly. 

     

    If contain data:

    name of the document would be "File name_lastModifiedDateTime.pdf"

     

    If did not contain data:

    name of the document would be "File name_lastModifiedDateTimex.pdf"

    for example:

    File name_24-05-12x.pdf (with a x behind to indicate that the document did not contain data)

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @memento 

     

    I think you need to integrate the data validation in pdf once after the pdf files are created from mail attachments.

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • memento Profile Picture
    on at

    How can this be done?  Any example ?

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @memento 

     

    Take this example- I have used AI Builder to get the pdf content and using this u can integrate this before file is created after retrieving attachment content from email.

     

    1. Use email trigger and use filter array to filter the attachment details which are not inline

    Nived_Nambiar_0-1716097452385.png

     

    2. use apply to each to loop through filtered attachments 

    Nived_Nambiar_1-1716097935398.png

     

    Steps to be followed inside the loop

     

    2.1- Get Attachment content of pdf file using Get Attachment Content action

    Nived_Nambiar_2-1716098022232.png

     

    2.2- use content bytes from get attachment content to get text from pdf if present 

    Nived_Nambiar_3-1716098148621.png

     

    2.3- use condition to check if it has data in pdf using output from AI Builder's action (step 2.2- output)

    Nived_Nambiar_4-1716098419156.png

     

    Expression- 

    length(first(outputs('Recognize_text_in_an_image_or_a_PDF_document')?['body/responsev2/predictionOutput/results'])?['lines'])
     
    If the condition is True- it means there is data in pdf, use create file action like below in Yes branch
    Nived_Nambiar_5-1716098500144.png

     

    Expression - 

    concat(split(items('Apply_to_each')?['name'],'.')?[0],'_',formatDateTime(outputs('Get_Attachment_(V2)')?['body/lastModifiedDateTime'],'yyyy-MM-dd'),'.',split(outputs('Get_Attachment_(V2)')?['body/name'],'.')?[1])
     
    if condition is False- empty content in file so create a file adding x at end of file name
    Nived_Nambiar_6-1716098584401.png

     

    Expression - 

    concat(split(items('Apply_to_each')?['name'],'.')?[0],'_',formatDateTime(outputs('Get_Attachment_(V2)')?['body/lastModifiedDateTime'],'yyyy-MM-dd'),'x.',split(outputs('Get_Attachment_(V2)')?['body/name'],'.')?[1])
     
    See below how it finally creates the files 
    Nived_Nambiar_7-1716098617252.png

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • memento Profile Picture
    on at

    Hi @Nived_Nambiar 

     

    There is an error message:

     

    Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'Apply_to_each' referenced by 'inputs' in action 'Create_file' are not defined in the template.'.'.
  • memento Profile Picture
    on at

    I did exactly the same flow

     

    memento_11-1718000133694.png

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 315 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 267

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard