529 total views, 11 views today
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
- How to encode and decode base64Binary datatype in Oracle BPEL - December 11, 2017
- How to Read a File using Oracle BPEL File Adapter Example - December 11, 2017
- How to write a File using Oracle BPEL File Adapter Example - December 10, 2017