Closed slemale closed 1 month ago
Hello Sébastien,
Thank you for your feedback, and I'm glad you find the PCF control useful!
I just wanted to inform you that you can't directly interact with the PCF control using external scripts like JavaScript, as PCF controls are self-contained as per my knowledge. However, to achieve your requirement of hiding certain options and disabling others, here's a solution that could work:
You can create two separate fields on the form — one to hold the options that should be hidden and another for the options that need to be disabled. On form load, you can set these fields with the appropriate values. The PCF control will rerender, pulling its data from the fields it is bound to, and apply the hide/disable logic based on those values.
This way, everything stays within the PCF logic, and you'll still have the flexibility to manage which options are hidden or disabled through those additional fields.
Let me know if that works for you!
Best regards, Sahil A
Hello Sahil,
Thank you for your answer. After testing JS interracting with PCF, I thought it was indeed not possible. Thanks for confirming ;)
Regarding your suggestion, I have to say I do not understand the solution. So let me explain with a case :
The optionset above is used by two different businesses (Food and Farm) And each business should only see values related to the business. What I do currently is remove unwanted values with JS. In the screenshot above, first 3 values should be hidden for Farm business.
Now thanks to your PCF, I would like to disable two values for Farm business because they are not used anymore for new records but are still necessary for old records.
What would be great is to be able to hide values and disable other values in the same optionset.
Hope it is clear enough :) Let me know if it is not possible of course, then I'll hide all values without disabling.
Thanks again for the job done here !
Sébastien.
Hello Sébastien,
I understand that you need to hide and disable specific options within an option set based on business.
While direct JavaScript interaction with PCF controls isn't feasible, here's a refined approach that should achieve your goal:
For dynamically hide/disable fields based on form field values -
Create Additional Fields:
HiddenOptions: A text field to store the option values you want to hide. (Add/Set values using JS on the onload of the form)
DisabledOptions: A text field to store the option values you want to disable. (Add/Set values using JS on onload of the form)
Populate Fields on Form Load: Use JavaScript populate these fields with the appropriate option values based on the business entity. For instance, for the "Farm" business, you would set "HiddenOptions" to "Option 1, Option 2, Option 3" and "DisabledOptions" to "Option 4, Option 5".
Bind Fields to PCF Control: Bind the "HiddenOptions" and "DisabledOptions" fields to your PCF control.
Implement Logic in PCF Control: Within your PCF control's JavaScript code, access the values of the "HiddenOptions" and "DisabledOptions" fields.
using this approach, when you change the values in the bind fields (HiddenOptions/DisabledOptions) using js on clientSide then pcf rerender and working as per your requirement.
Take the unmanaged solution and modify as per requirement - solutions
Hello Sahil,
Thanks for this useful information. I'll see with my dev team as I am not a developer myself. Thanks again !
Sébastien.
Hello,
Thank you for your work here, this PCF is a very useful. One question : would it be possible to hide certain options and disable other options at the same time ? (not the same options of course) I tried to use the PCF to disable options on an OptionSet and use a JS on the side to hide other options but JS is not taken into account when using a PCF.
Let me know if this could be possible. Thanks again for this !
Sébastien.