Skip to Content

Visual Composer Explorations: Using Portal Roles to influence UI Element Behavior

We were once creating a Visual Composer (VC) prototype for a customer and one requirement was the ability to adapt the User Interface (UI) based on the user role in the portal.

After asking in the Visual Composer forum if this was standard functionality and receiving the answer that this was not possible,  I decided to create a solution on my own.  The components that were necessary were:

  • A simple Web-Service to return the roles for a particular portal user.
  • An invisible output form in VC to store the values that come from the web-service.
  • Input fields with visibility conditions in a VC form to respond to the information from the web-service via the invisible output form.


We created a web-service in Web Dynpro (Thanks to colleagues in Rumania for their assistance in this regard) that has one input parameter (the portal user unique id) and returns a single string with all portal roles.  We used the @uniquename field from the user data object as the input to the web-service.

The meat of the web-service is listed below:

  * Business Method.
 public String GetAllRoles(String userGID) {
  String response="";
   Iterator rit = null;  
   IUser user = UMFactory.getUserFactory().getUserByLogonID(userGID);
   rit = user.getRoles(true);
   IRoleFactory rfact = UMFactory.getRoleFactory();
   while (rit.hasNext()) {
    String roleName = (String);
    IRole role = rfact.getRole(roleName);
    response+=" --- "+role.getUniqueName();
  catch(Exception e)
   response = showStackTrace(e);
  return response;

For a Web Dynpro developer, the rest of development work (creating a web-service, etc) should be relatively straight-forward and is therefore not included in this blog.

Invisible Form

The first step in VC was the creation of an invisible form that was fed from a web-service.  I used the trick that was described in All About Visual Composer to use an output form with visibility condition set to false. The response from the web-service is passed to the form.

Now some of you might be wondering why there is a data store present as well.  I tried to use a data store to hold the info but for some reason it didn’t work. Maybe someone can fix the problem and write me a comment why it didn’t work.

VC Form with visibility conditions

I created an IView with two layers (Wizard style Navigation Control). The first form just contained a button to show the second layer with the input form contains input fields with visibility conditions.

The visibility conditions were based on a simple formula which examined the values in the invisible form that received the response from the web-service

BOOL(CONTAINS(#ID[ACAEM]@Response,"")  <1)  

If I had used the data store, the formula would have looked something like this.

BOOL(CONTAINS(STORE@Roles,"") < 1)  

For the example, I just used a single value from the invisible form’s field.  In more complicated environments, you could use “AND” and “OR” operators to deal with multiple roles.

You must be Logged on to comment or reply to a post.