Question

I have a requirement in Openbravo 3.0 framework . I have two user one is HR and the other is employee . Their is a checkbox in user window called HR USER .. In my window I need to write a read only logic so that when HR logins the record has to be editable , and when the employee logins the record has to be non editable,, I know how to do that for normal fields ,, But i am not getting anything about user validation.. In the employee screen i am assigning the user id to that employee.

Please Help

Was it helpful?

Solution

Read Only Logic based on Logged in User:

  1. finding out the ID (primary key) of the User (HR or Employee) using PGAdmin Query tool.
  2. Add read only as shown below.

enter image description here

Read Only Logic based on Logged in Role :

This can be achieved in three steps

  1. creating Auxiliary Input.
  2. finding out the ID (primary key) of the role (HR or Employee)
  3. associating Read Only Logic to the Column.

First of all, we need to add an Auxiliary Input that will make AD_ROLE_ID of the currently logged in user available to the user window. Using the System Administrator role navigate to the Application Dictionary || Setup || Auxiliary Input and create a new record as shown below:

enter image description here

This will make the #AD_ROLE_ID session variable available to the [user] tab of the HR User window through the @ROLE_ID@ variable.

Secondly, you need to find out what the AD_ROLE_ID of the HR role is. Use the PgAdmin to query the AD_ROLE table and find that out. A simple query reveals the following:

 select ad_role_id, name from ad_role;

 ad_role_id                        | name
 ----------------------------------+---------------------------
 ....
 1000001                           | Admin
 SDJFALSDFJKLASJDFKLASDFASLDFJAKLSJ| velmurugan 
 SDFLAKSDJFLKASJDLFALSDFALDSKFJLAS | Employee
 DSKLFJAKLDSJFKLASJFKLADSJFLKAJSDFK| F&B US, Inc. - Admin
 ....
(38 rows)

The primary key (AD_ROLE_ID) of the HR role is 054A32701D6D4CE6BF4F695DAB23EDB3. This will clearly be different in your case.

With this information, we can now find the HR User field definition and set its Read Only Logic to @ROLE_ID@!'054A32701D6D4CE6BF4F695DAB23EDB3' as shown below:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top