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
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
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
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
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
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
WarrenBelz
109
Most Valuable Professional
Michael E. Gernaey
72
Super User 2025 Season 1
mmbr1606
71
Super User 2025 Season 1