Forum Discussion
fmourtaza
May 12, 2023Copper Contributor
NewForm with Conditional Formula
Hello Folks,
I would like to achieve a simple functionality based on a DropDownList.
Let us say that whenever a user select Choice1, some value has to be set in the Test column.
I tried using Conditional Formula, however it accepts only True or False - nothing else.
=if([$Choices] =='Choice1', 'true', 'false')
Show or hide columns in a list form | Microsoft Learn
Any alternative?
Thanks in advance.
- Deleted
you can achieve the desired functionality using SharePoint Framework (SPFx) extensions. Specifically, you can create a Field Customizer extension to handle the conditional logic based on the choice field selection. Here's an outline of the steps:
1. Set up the development environment:
- Install Node.js and Yeoman.
- Install the SharePoint Yeoman generator by running the command: `npm install -g @microsoft/generator-sharepoint`.
- Create a new SPFx extension project by running the command: `yo @microsoft/sharepoint`.2. Implement the Field Customizer extension:
- In the generated project, locate the `FieldCustomizer` folder.
- Add logic in the `onRenderCell()` method to handle the rendering of the custom field.
- Within this method, use JavaScript to check the selected choice value and update the text field accordingly.3. Package and deploy the extension:
- Build the SPFx solution by running the command: `gulp bundle --ship` followed by `gulp package-solution --ship`.
- Upload the generated `.sppkg` file to the App Catalog in your SharePoint tenant.
- Approve and deploy the extension to the desired site.4. Associate the Field Customizer with the choice field:
- Go to the list where the choice field exists.
- Open the list settings and click on the choice field.
- Under the "Column Formatting" section, set the Custom Formatter to the ID of your Field Customizer extension.By following these steps, your Field Customizer extension will be associated with the choice field in the modern SharePoint experience. It will render the custom field based on the selected choice, allowing you to set the value of another text field dynamically.
For more detailed instructions and code examples, you can refer to the official SharePoint Framework documentation on Field Customizers. https://learn.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-simple-field-customizer
If I have answered your question, please mark your post as SolvedIf you like my response, please give it a like