How to make input fields mandatory in CRM WEB UI
You want to make an input field mandatory so that a user is unable to save changes unless the required field is not empty.
If you created the BSP component from scratch you’re probably well aware of how to do this. But this example is based on making a field in a standard SAP component mandatory.
Here I wanted to make my change to the Service Request details page. A user should not be allowed to save a service request they edited if they do not have level 1 or level 2 categories specified.
- Discover UI component and view used via pressing F2 on the field in the WEB UI
- For my example the Component is BTCATEGORIES and the view is BTCATEGORIES/Categories
- Go to UI Component Workbench (transaction BSP_WD_CMPWB)
- Open the View, navigate to the UI Configuration Tool tab, copy the configuration currently used and specify Role Key, Component Usage, Object Type and Object Subtype.
- If you’re unsure of what parameters to use, hitting F2 on the field in the WEB UI will show you what parameters are being searched for.
- I advise you to read more about what these mean as you could be changing the configuration for more than just your intended scenario.
- In new configuration scenario, select the field you’re after, click ‘Show Field Properties’, check the Mandatory check-box.
- Apply and Save. Restart Web UI browser to view the change.
When a user clicks ‘Save’, the eh_onsave() method checks all mandatory fields in the screen for any that are blank. If one is encountered it cancels the save and highlights the blank fields with a red border.