How to access other View object attributes using Groovy
In this section, we talk about accessing other view object column name using Groovy.
Create Employee & Job View Object (Click here for the instruction to create Entity & View Object from a table )
We are adding an attribute ‘SumOfSalary’ in Job View Object. The column SumOfSalary refers Employee table Salary column.To access Employee VO from Job VO, we must create ViewAccessor for Employee. ViewAccess is a gateway to access other VO.
Double click on the Job View Object >> select View Accessor >> Click + icon to add ViewAccessor >> Drag EmployeeEOView to right and click Ok
The ViewAccessor will get created. Copy the ViewAccessor name, i.e., EmployeeEoView1; we need this name to specify in our Groovy expression
Now Click on the Attribute tab >> Click + icon >> Add an attribute called SumOfSalary and type as BigDecimal as shown below >> Click Ok
Choose the column SumOfSalary >> Select Detail tab >> Enable Expression >> Click expression icon
Type the Groovy expression as shown below and click Ok. Here we are adding a groovy expression that fetches sum of salary from Employee table and put into SumOfSalary column
adf.object.EmployeeEOView1.sum(“Salary”) //It is similar to Select sum(salary) from employee
Test the Groovy
Right click the AppModule.xml and click Run >> Double click the JobEoView1 >> Test the Sum OfSalary is coming correctly
The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.
Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
Latest posts by Govind
- P6 Progress Reporter completely integrated into P6 Team Member - August 15, 2017
- Primavera P6 Professional for EPPM Popup 16.2 : The appropriate industry for your organization has not yet been select in admin preferences - August 15, 2017
- Primavera P6 Background Job Error:Creating job Symon Failed to add Database Job, Check the settings table for valid interval values for dbms_scheduler - August 14, 2017