Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

Select only one file from OneDrive Business

(0) ShareShare
ReportReport
Posted on by 66
Hi Everyone,
 
I'm creating customized emails to my customers that includes monthly reports for the products they are using.
 
My monthly reports are in a OneDrive Business folder and named as:
  • Monthly Report-Windows.xlsx
  • Monthly Report-Mac.xlsx
  • Monthly Report-Linux.xlsx
 
One customer receives only one report - e.g. 
  • Customer A > Monthly Report-Windows.xlsx
  • Customer B > Monthly Report-Linux.xlsx
  • Customer C > Monthly Report-Mac.xlsx
 
I'm using Graph API to create draft emails and I'm then sending them. 
 
My challenge is including the report in the Graph API call. I select the files using "Find files in folder" to get the unique FileID, but the next step is always for-each loop, even if I select one file to return:
 

How can I select one specific file so that I can include it in the API Call? 
 
Thank you!
 
Cheers,
Tolga
  • tolga-balci Profile Picture
    tolga-balci 66 on at
    Select only one file from OneDrive Business
    Hi All,
     
    Thanks very much for the answers. Here is a bit of clarification (@David_MA)
     
    I have the following files under a OneDrive folder:
     
     
    I want to select one file from this directory - e.g. "Monthly Report-Windows.xlsx"
     
    Once I select this one file, I will get its name and content bytes stored in variables to use in a Graph API call:
     
    {
    "@odata.type": "#microsoft.graph.fileAttachment",
    "name": "Monthly Report-Windows.xlsx",
    "contentBytes": "R0lGODdhEAYEAA7"
    }
     
    In another step, I will do the same, but for another file - e.g. "Monthly Report-Linux.xlsx", and then get its name and content bytes, use those in another Graph API call. The reason for this is to satisfy the business requirement as I mentioned before - one customer receives only one report, therefore there will be different Graph API calls for each customer:
    • Customer A > Monthly Report-Windows.xlsx
    • Customer B > Monthly Report-Linux.xlsx
    • Customer C > Monthly Report-Mac.xlsx
     
    Hope it's clear now.
     
    Thanks much!
     
    Cheers
  • Pstork1 Profile Picture
    Pstork1 64,909 on at
    Select only one file from OneDrive Business
    If you always want the first file to be returned you can always use the first() function to avoid the loop and select the first file.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • David_MA Profile Picture
    David_MA 9,039 on at
    Select only one file from OneDrive Business
    I think you need to take a different approach, which I cannot tell you how without better understanding your goal.  Your flow does not look correct based on what you describe. If you use the Get files action and limit it to 1 file, how can you be sure the correct file out of the three is the one that should be sent? If you don't care which one of the files is sent, then what @Hardesh15 said would be true.
  • Suggested answer
    Hardesh15 Profile Picture
    Hardesh15 7,087 on at
    Select only one file from OneDrive Business
    I don't think there is any issue. Find files action is returning a collection which is why it is applying a loop. If you are selecting only one file then it will work only for that file not for other files.
     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard