Hi All!
First of all, i hope you are having a good time, according with the current crisis , of course.
I'm having a splitting headache with i think it will be a really silly problem, which am going to explain down below.
I've created a PCF to "Replace" a "Choice" field with what is basically the same think But when the option is equal to a configured target, it changes color to all user's attention. it works fine on my machineâ„¢, so i uploaded to our D365 Org. Actually Works! Until you navigate out from the form and open another record from the same table (which indicates had a problem loading, print below). Does anybody got this before? this is not the first time it happened, but i just abandoned the idea and replace it with an WebResource. so it looks that i do something consistently wrong. Other PCFs (from PCF Gallery) Work just fine.
you can find the code here: https://github.com/numsantos/Color-Field-PCF
and the prints with the Error (Could not fin/invke Xrm.Sparkfish.PCF.ColorField's constructor):
Prints of it Working and then not working by navigating back to the accounts view and again to a record:
Does anybody finds what is wrong in the code ?
From a quick glance through, I see two things:
- One, you are redundantly calling render. If you have it in updateView, there is no reason to call it in init.
- Two (and much more important), your html injection in the tsx is crazy. You're trying to reproduce MSFT html and it is bound to bite you in the butt. You will find it MUCH easier and MUCH MUCH safer to use Fluent UI React Components to build things like an optionset. Try this one: Home - Fluent UI (microsoft.com)
WarrenBelz
55
Most Valuable Professional
mmbr1606
42
Super User 2025 Season 1
Michael E. Gernaey
31
Super User 2025 Season 1