I have a scenario where the fields in UI should be displayed based on User roles. For Example- If user is from role "A" then UI will display 5 fields but if the user is from role "B" then there will be 10 fields.
To accomplish the above design, I am thinking of using Drools rules engine. After user logs into the application, Frontend calls the API "/user/fields?Id=". The API first gets collection of field names and user role mappings from a DB table that is prepopulated and send all the mappings and logged in user's role to Drools. Drools will return the list of fields names matching the user's role and then send it to Frontend. Frontend is in Angular which will display or hide based on the lists.
I am using Java, Spring Boot for API and Angular for frontend. Is there a better approach or more efficient way of doing it?
Drools and other business rules engines are designed and best at handling complex decision trees. For trivially simple scenarios and applications, they tend to be out-performed by simple comparisons implemented in Java (eg. if/else trees.)
What you've described falls more on the "trivially simple" side of things. There's nothing in the proposed use case that indicates that you'd need or benefit from a business rules engine. Java 'if' statements will likely be more performant and require fewer resources and overhead.