Role based access to dashboard entries


Problem Statement:

Business of any type may require quick access  to information in a customized way and it must be intuitive to read and interpret. In Adempiere, the Dashboard is short, simple and direct way to summarize business critical information. Dashboard plays a major role, when user wants to see data about different areas in  business as soon as he/she logs-in.

At the same time business expects access controls for the this dashboard content. Every one should not have access all the dashboard content. There need a role based access access mechanism for dashboard entries. ADempiere does not provide this functionality as part of core functionality.

Scope of Article:

As a part of this article we will discuss about how to create dashboards in Adempiere and steps to give access on these dashboards to Specific Roles.

Technology:

• ADempiere 342 or above

Details:

Let us take the example of application where business raises purchase orders to multiple suppliers. When the supplier logs-in, he would like to see New, Pending, Overdue Purchase Orders of against themselves.

  1. Create a entry in Dashboard content window for Purchase OrdersDashboardEntry
  2. Login as supplier and see the dashboard. SupplerLogin                         As Role based access is not given, even after login as supplier, user will not be able to see the dashboard entry
  3. Login as administrator and give permissions for this dashboard entry to supplier role. Open Role window and open supplier role tabAccessPermissions
  4. Go Open Dash board access tab and select the relevant dashboard entryGrantPemissions
  5. Now Login as supplier and see the dashboard

SupllierLoginwithDashboard

On this Dashboard Supplier can see New,Pending,Overdue Purchase Orders of login Supplier.

Changes Made:

  • Added new table PA_DBoardContent_Access table to store access level controls
  • Make changes in dashboard rendering functionality to render dashboard entries based on access controls
    • DefaultDeskTop.java

      public void initDashboard(){
      …………….

      int userId = Env.getAD_User_ID(Env.getCtx());
      /**
      * Bug 1479
      * Added join to PM_DBoardContent_Access table while getting data for the dashboard
      *
      */
      String sql = “SELECT x.*,pud.*, m.AD_MENU_ID ”
      + “FROM PA_DASHBOARDCONTENT x JOIN PM_DBoardContent_Access pdca ”
      +” on x.PA_DASHBOARDCONTENT_ID = pdca.PA_DASHBOARDCONTENT_ID ”
      + ” JOIN PM_User_DashBoard pud on pud.PA_DASHBOARDCONTENT_ID = x.PA_DASHBOARDCONTENT_ID”
      + ” LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID ”
      + “WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE=’Y’ and ”
      +” pdca.ad_role_id = ? and pdca.isActive = ‘Y’ ”
      +” and pud.ad_user_id = ? ”
      + “ORDER BY TRUNC(pud.LINE), pud.COLUMNNO “;

    •  MDBoardContentAccess.java(newly created model class)

      public MDBoardContentAccess (MDashboardContent parent, int AD_Role_ID)
      {
      super (parent.getCtx(), 0, parent.get_TrxName());
      setClientOrg(parent);
      this.setPA_DashboardContent_ID(parent.getPA_DashboardContent_ID());
      setAD_Role_ID (AD_Role_ID);
      } // MDBoardContentAccess

    • MDashboardContent.java

      protected boolean afterSave (boolean newRecord, boolean success)
      {
      /**
      * Create access entry for all the roles in default, if user does not want to see
      * this dashboard for a particular role, just they will make it inactive
      *
      */

      if (newRecord) // Add to all automatic roles
      {
      MRole[] roles = MRole.getOf(getCtx(), “IsManual=’N'”);
      for (int i = 0; i < roles.length; i++)
      {
      MDBoardContentAccess dba = new MDBoardContentAccess(this, roles[i].getAD_Role_ID());
      dba.save();
      }

      MUser[] users = MUser.getOf(getCtx(), null,this.get_TrxName());
      for (int i = 0; i < users.length; i++)
      {
      MUserDashBoard udb = new MUserDashBoard(this, users[i].getAD_User_ID());
      udb.save();
      }

      }
      return success;
      } // afterSave

Summary :

As a part of this article we learned about creating entries of dashboard and giving access to particular role for the created Dashboards. Giving access to the roles plays a very important role in both sharing and hiding the business critical information between different roles existing in the system.

Walking Tree promotes Adempiere and we support the users as well as the developers to ensure that the business is able to take complete advantage of Adempiere’s wonderful capability. In case you are looking for a professional assistance then do visit our website to get in touch with us.

References :

Tagged with: , , , ,
Posted in ADempiere, EagleRP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: