Have you ever encountered an issue where you have multiple properties configured in your Control Manifest file and you configured it correctly in Model-Driven app. But for some reason you do not get the value from the field that was bound in the configuration.
For example I had my Control Manifest file as below.
<?xml version="1.0" encoding="utf-8"?> <manifest> <control namespace="PowerMaverick" constructor="NewControl" version="0.0.47" display-name-key="NewControl" description-key="NewControl" control-type="standard"> <!-- property node identifies a specific, configurable piece of data that the control expects from CDS --> <property name="Text1" display-name-key="Text1" description-key="Text1" of-type="SingleLine.Text" usage="bound" required="true" /> <property name="Text2" display-name-key="Text2" description-key="Text2" of-type="SingleLine.Text" usage="bound" required="true" /> <resources> <code path="index.ts" order="1" /> </resources> <feature-usage> <uses-feature name="WebAPI" required="true" /> </feature-usage> </control> </manifest>
As you can see I have two properties: Text1 & Text2. When I configured my control in model-driven app I specified Account Name and Account Number (shown below).
Even though my records have account number populated, but I do not have it on the form. When the form loads account number does not populate on my PCF Control. When I started debugging I identify that the property is empty.
What could have possibly gone wrong!!
Once I added the field on the form (if you want keep it hidden) – BINGO!! – I was back in business. My PCF Custom Control started showing the value.
So, in case you run into issues where your property is retrieved as empty in your code check if the attribute associated to that property is present on the Form (hidden or visible).
Want to learn more about PCF Custom Controls take a look at my video: https://youtu.be/ylhVZUlGgQw