MultiSelectOptionSetControl - OptionSet Options undefined
PabloTomasParejaAtFundae opened this issue · 4 comments
PowerApps-Samples/component-framework/MultiSelectOptionSetControl/MultiSelectOptionSetControl
Error occured during initilization of control: SampleNamespace.MultiSelectOptionSetControl;Message: Cannot read properties of undefined (reading 'forEach')
TypeError: Cannot read properties of undefined (reading 'forEAch') at multiSelectOptionSetControl.init
Options property is undefined:
// Create a select option for each option specified by the target OptionSet and add it to the dropdown
(context.parameters.controlValue as ComponentFramework.PropertyTypes.MultiSelectOptionSetProperty).attributes?.Options.forEach
@jopursle
I can reproduce the error with these steps:
- Clone the repo, navigate to the
\component-framework\MultiSelectOptionSetControl\
folder and open it using VS Code. - In a terminal window, run
npm install
. - Run
npm run build
- Run
npm start watch
The test harness launches.
Expected:
The control should load.
Actual:
The error reported by @PabloTomasParejaAtFundae occurs.
@PabloTomasParejaAtFundae
I have been told that this behavior may be expected for this particular sample, and that the control works as expected when you actually use it.
I'm waiting for @jopursle or another dev on the engineering team to confirm this, so we can update the docs to include a mention that this is 'by-design'.
@PabloTomasParejaAtFundae I have been told that this behavior may be expected for this particular sample, and that the control works as expected when you actually use it.
I'm waiting for @jopursle or another dev on the engineering team to confirm this, so we can update the docs to include a mention that this is 'by-design'.
That is correct. Once the component is applied you have access to the Options property and the code works.
But the development has to be done blindly or, as a workaround, define the component in the manifest as OptionSet in order to have access to the Options and change type and outputs just before deploying the component.
Ideally I would like that in the harness a default set of options is loaded in the same way as it is done when the property is of type OptionSet.
Thanks.
I added the following note to the readme for this sample:
NOTE
When you run try to run this sample using the test harness, you will get the following error:
Error occured during initilization of control: SampleNamespace.MultiSelectOptionSetControl;Message: Cannot read properties of undefined (reading 'forEach')
TypeError: Cannot read properties of undefined (reading 'forEach') at multiSelectOptionSetControl.init
The reason is that the option set control data can't be simulated/mocked in the test harness. This sample will only run correctly when you configure it for a field in a model-driven app.