cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tvd_nzi
Advocate II
Advocate II

fireOnChange() not triggering pcf update view

Hello everyone,

 

I'm not 100% sure of this even working but I believe it should.

 

A dynamics 365 pcf on a form has as input an optionset. This said optionset is set to never submit value on save (setSubmitNever) but still gets modified and needs to pass changed value to the pcf but this does not happen if the value doesn't get saved. Is that the correct behaviour? Shouldn't fireOnChange() still trigger the pcf? Afaik this worked for quite some time and we've lately discovered that it's not the case anymore and fireOnChange() doesn't trigger any pcf update.

 

Thanks in advance and best regards,

David

5 REPLIES 5
skoofy5
Super User
Super User

So you've got formContext.getAttribute(pcf).setSubmitMode('never') on an optionset with a bound PCF and you're using formContext.getAttribute(pcf).fireOnChange() to try and trigger a re-render of the value?

The doc kind of implies it's also blocked for editing, but you're right, I don't know if that's always been the case - https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/attribut...

"The data is never sent with a save. When this value is used, the column(s) in the form for this column cannot be edited."

I suppose to check if it's the submit mode causing the issue you could test without changing the submit mode?

Thanks for your reply.

 


@skoofy5 wrote:

So you've got formContext.getAttribute(pcf).setSubmitMode('never') on an optionset with a bound PCF and you're using formContext.getAttribute(pcf).fireOnChange() to try and trigger a re-render of the value?

Not quite. setSubmitMode 'never' is set for the optionset bound to the pcf as input. The fireOnChange is called for the optionset when it has programatically been changed. So formContext.getAttribute(optionsetAttr).setSubmitMode('never') and formContext.getAttribute(optionsetAttr).fireOnChange(). But setting a new value for the optionsetAttr and calling fireOnChange() doesn't update the property bag of the pcf.

I found the same question on github and ms says it's by design that the pcf doesn't update when fireOnChange() is called regardless if setSubmitMode set.

How then would you track bpf phase changes in a pcf to show different data based on the selected phase?

The BPF is also tracked as a related entity. Changes to your BPF stage should immediately be reflected in the related records there. Build your PCF on a dataset template and then attach it to a subgrid showing those.

cchannon
Super User
Super User

@tvd_nzi did these posts help solve your issue? If so, please mark a solution so future readers can see.

Hi @tvd_nzi , 

 

To track the changes of a BPF, you could use a second bound property in your PCF; set a different value for this dummy property each time you want your updateView PCF method to get triggered.

 

This property could be something you change anyway when the BPF stage changes: like a dummy optionset  on the form, reflecting the stage.

Or just take a date as a second parameter and set it to the current datetime each time the BPF changes. You can use form scripting, and attach to the process stage changed event, and set there the datetime value to your dummy field.

 

Hope this helps!

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Users online (1,071)