Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Retrive selected Items from PCF dataset in custom page

(0) ShareShare
ReportReport
Posted on by 18

Hello,

 

I created a PCF that includes a Details List. When the items are selected and on click of the button found on the custom page, I want the records to be retrieved in the custom page and created a record of them in another table.

 

this is the popup that includes the pcf dataset and the button which is added from the custom page components.

Mhmdbaba_0-1665471809221.png

 

My aim is to retrieve the records selected on my custom page when the button is clicked.

I will be attaching the index.ts and components.tsx in this Post.

 

Thank you!

 

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Retrive selected Items from PCF dataset in custom page

    Hi @Mhmdbaba , 

    I think it should work now. I had a look at my repository. I set also the DetailsList selectionMode={SelectionMode.multiple}.

    I also wrap the DetailsList in a 

    <MarqueeSelection selection={selection}>
     <DetailsList //goes here
     />
    </MarqueeSelection

    Not sure if that makes a difference.

     

    What exactly doesn't work with setRecordIds?

  • MBaba Profile Picture
    18 on at
    Re: Retrive selected Items from PCF dataset in custom page

    Hi @DianaBirkelbach,

     

    I managed to use the dataset in my code and make use of it, but I am facing a problem in setRecordIds for the dataset.

    I will attach my code here. I hope you would reply.

     

    Thank you!

  • MBaba Profile Picture
    18 on at
    Re: Retrive selected Items from PCF dataset in custom page

    Hello @DianaBirkelbach ,

     

    Thank you for your time in reviewing my code and helping me. I will be trying this approach and update you when done.

     

    Thank you!

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Retrive selected Items from PCF dataset in custom page

    Hi @Mhmdbaba ,

     

    From the code, I see that you have a dataset PCF, but you actually don't use the data provided by the dataset.

    Basically you make a webAPI request by yourself to get the records.  That way it's hard to interact with the CustomPage.

    You could declare another output property in your manifest, and pass that value in yout getOutputs() method, containing the selcted id. Then you can access that output property fromn your Button. But I wouldn't recommend it.

     

    A better approach would be to let the platform work for you.

    1. make use of the dataset property you've declared inside your manifest. This will contain the data provided by your CustomPage. The definition of the data will be made using PowerFx (get a dataSource in your CustomPage and filter the data as needed using PowerFx)

    2. inside your component you can use the dataset.records provided, to show the data.

    3. The dataset has a method to set the selectedRecordIds: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/dataset?WT.mc_id=BA-MVP-5004107#methods. If you set that inside your PCF, you are able to access the selectedRecord outside the PCF (in your CustomPage)

    4. In the CustomPage, define the OnSelect function for your button. Set oit as <YourPCF>.Selected like in the screenshot below (of course, through the ".Selected " you have access to the fields inside the collection). 

    DianaBirkelbach_0-1665476281217.png

     

    Actually there is a FluentUI dataset PCF, ready to use, made by the Microsoft Power CAT team. You can find it in the Creator Kit: https://powerapps.microsoft.com/en-us/blog/introducing-the-creator-kit-efficiently-create-performant-fluent-ui-based-power-apps/. There are 3 solutions: one with the PCFs (not only the FluentUI  DetailsList, but a lot of others), and demo solutions (one of them fpr CustomPages - in the MDA solution).

     

    PS: By the way, using the Xrm object inside the PCF is not supported. If you need webAPI Requests, you must declare the usage inside the manifest, and get yout webAPI object through context.webAPI: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/context?WT.mc_id=BA-MVP-5004107#webapi

     

    Hope this 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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 109 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 76 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

Overall leaderboard