Skip to main content

Notifications

Community site session details

Community site session details

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

Invoke ribbon action function from PCF control

(0) ShareShare
ReportReport
Posted on by 30

Hi Guys,

 

Is there a way we could invoke javascript function through PCF control which are bind with ribbon actions?

 

actually I can see that js file as web resources loading into browser which contain those methods but they are in separate iframe so my PCF control can't able to see them ... and can't able to make call to these javascript methods.

 

I want to simulate these ribbon button menu inside my PCF through context menu, but the bottle neck is to have access to those javascript functions 😞

 

I would appreciated any help 🙂

 

Regards,

Awais

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Invoke ribbon action function from PCF control

    I've got it now @awais .

    An alternative could be making Virtual Entity out of JSONs, and using the rest of the logic without a PCF. Just a thought, in case it helps you stay supported and  it's not too complicated.

    Kind regards,

    Diana

  • awais Profile Picture
    30 on at
    Re: Invoke ribbon action function from PCF control

    Hi @DianaBirkelbach 

    Thanks, I don't thing I can use Dataset PCF, actually I am building records from custom json of all connections record and thy are not related with one type of entity.

    Ribbon bind with OOB grid is existing logic which I am trying to use as is in my PCF 🙂 

    Regards,

    Awais

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Invoke ribbon action function from PCF control

    Hi @awais ,

    Not sure if I've got the use case to the end, but I wanted to check that you are aware that the Dataset PCFs are able to select records, which the ribbon can interact with. Exactly like the OOB Grids.

    You can use dataset.setSelectedRecordIds: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/dataset/setselectedrecordids

     

    Maybe you don't need to go the hard way to trigger the ribbon action. 

     

    Kind regards,

    Diana

  • awais Profile Picture
    30 on at
    Re: Invoke ribbon action function from PCF control

    Thanks @DianaBirkelbach,

    It is Field PCF control. actually I don't want to access formContext, basically some existing ribbon actions exists to do some operations against OOB subgrid selection. Now in my PCF I want to perform same operations on my react-ui detailList control selection.

     

    I will try your postMessage suggestion. 

     

    Regards,

    Awais

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Invoke ribbon action function from PCF control

    Hi @awais , 

     

    From a PCF you cannot acces the Javascripts on the form or ribbon, at least not supported.

    Is it a Dataset PCF or a Field PCF?

    If it's a script that you wrote, and you don't access the formContext in the script, maybe you can include it in your PCF?

     

    The only kind of "events" you can trigger from the PCF is changing values of the bound attributes. Maybe you can introduce a new "dummy" attribute, when you want to trigger the function, change it's value inside the PCF and let  the ribbon script attach to this "OnChange" event.

     

    If that's not an option, but you can change the  script behind the ribbon function (and you cannot solve the problem in another way), maybe you can try using postMessage inside the PCF and let the ribbon script listen to this message. The problem is that you would need to send the message to all the frames, because you don't know where the ribbon scripts will be loaded. It's not very bad, since the other Frames will ignore your message. I've wrote a blog about this (https://dianabirkelbach.wordpress.com/2020/05/15/can-pcfs-communicate/) but it's a bit of a gray zone. 

     

    Hope this helps 🙂

     

    Kind regards,

    Diana

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 72 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

Overall leaderboard