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 / Dynamically set refere...
Power Automate
Answered

Dynamically set reference type for Planner attachments

(0) ShareShare
ReportReport
Posted on by 12

I’m working on a automation that will trigger by filling a Forms and create a planner task. The automation will add files to the task from a SharePoint folder and I’ve successfully done it with “hardcoding” the files I want to add but I would prefer to have it dynamic since the files I add will most likely change over time.

 

Right now I can add files dynamically but one thing I can’t seem to solve is how to add Reference type dynamically i.e if I add a PDF file the reference type will be set to PDF and so forth. 

Categories:
I have the same question (0)
  • manuelstgomes Profile Picture
    6,625 on at

    Hi @MajorOfSweden 

     

    To do that, you need to build the entire array yourself. It's not complex, and you can check the structure by doing a test value. For example,

    Screenshot 2021-09-22 at 12.04.21.png

    When you press the "Switch to input the entire array", you'll get this.

    Screenshot 2021-09-22 at 12.04.26.png

     

    I wrote an article explaining how to add attachments to the email, but the concept is precisely the same. You can find it here:

    https://manueltgomes.com/microsoft/powerautomate/power-automate-add-attachment-to-e-mail-dynamically/

     

    The idea is to generate the JSON in an array variable and then use the join function to generate the final value.

     

    Can you please take a look at the strategy and see if it solves your problem?

     

    Cheers
    Manuel

    ------------------------------------------------------------------
    If I have answered your question, please mark it as "Accept as Solution." It will help other members finding the solution faster. If you like my response, please give it a Thumbs Up. ?
    Otherwise, reply to it, and the community will do its best to help you.

  • MajorOfSweden Profile Picture
    12 on at

    E6B71FD2-CE36-4A43-83C0-702AB8E6D4FF.jpeg

    5FD52B76-9861-4206-BF5D-BBE533D80BA1.jpeg

    Hi @manuelstgomes !

     

    Maybe my original post was a bit unclear since I wrote it after working a night shift. What to linked in your answer I’ve already accomplished using your article actually. The problem is that if I attach a PDF file planner won’t recognize it as PDF, it’s only recognized as a link to the SharePoint. My organization uses Planner through Teams desktop so it would be neat to have the most common file formats recognized so they can be opened within teams rather than opening the link in a web browser.

    I did manage to get it working for one file type using an array that iterates through all files in folder and use an If statement to look for “pdf” in file name and use return value as reference type. I would like to build on that to take more file types. See attached images.

  • Verified answer
    MajorOfSweden Profile Picture
    12 on at

    I've been working on this tonight and actually solved it even if it's maybe not the most effective way.
    I started with using Compose and insert a JSON formatted array with the file types and their corresponding reference types.

    [
     {
     "id": 1,
     "file_type": "pdf",
     "reference_type": "Pdf"
     },
     {
     "id": 2,
     "file_type": "ppt",
     "reference_type": "PowerPoint"
     },
     {
     "id": 3,
     "file_type": "pptx",
     "reference_type": "PowerPoint"
     },
     {
     "id": 4,
     "file_type": "xls",
     "reference_type": "Excel"
     },
    ..............

    I then used a Array filter like this:
    Skärmbild 2021-09-23 052247.png

    indexOf(outputs('Copy_file')?['body/Path'], item()?['file_type'])

    From here I add the corresponding reference type into my file array using:

    Skärmbild 2021-09-23 052837.png

    first(body('Filtermatris_2'))?['reference_type']

     I then use my file array to add references (attachments) to my planner task:
    Skärmbild 2021-09-23 053127.png

    All this is inside a Apply to each that goes through all files in a specified SharePoint folder.

  • manuelstgomes Profile Picture
    6,625 on at

    Hi @MajorOfSweden 

    Looks good! Well done. 😀

    If you can't finish for some reason, please let me know.

    Cheers
    Manuel

    ------------------------------------------------------------------
    If I have answered your question, please mark it as "Accept as Solution." It will help other members finding the solution faster. If you like my response, please give it a Thumbs Up. ?
    Otherwise, reply to it, and the community will do its best to help you.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 469

#3
11manish Profile Picture

11manish 364

Last 30 days Overall leaderboard