How to access other View object attributes using Groovy

In this section, we talk about accessing other view object column name using Groovy.

Pre-Requisite

JDeveloper 12.1.3

HR Schema

Create Employee & Job View Object (Click here for the instruction to create Entity & View Object from a table )

Process

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

050616_0150_Howtoaccess1 How to access other ADF view object attributes using Groovy

The ViewAccessor will get created. Copy the ViewAccessor name, i.e., EmployeeEoView1; we need this name to specify in our Groovy expression

050616_0150_Howtoaccess2 How to access other ADF view object attributes using Groovy

Now Click on the Attribute tab >> Click + icon >> Add an attribute called SumOfSalary and type as BigDecimal as shown below >> Click Ok

050616_0150_Howtoaccess3 How to access other ADF view object attributes using Groovy

Choose the column SumOfSalary >> Select Detail tab >> Enable Expression >> Click expression icon

050616_0150_Howtoaccess4 How to access other ADF view object attributes using Groovy

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

Syntax: adf.object<ViewAccesor>.<AggregateFunction>

050616_0150_Howtoaccess5 How to access other ADF view object attributes using Groovy

Test the Groovy

Right click the AppModule.xml and click Run >> Double click the JobEoView1 >> Test the Sum OfSalary is coming correctly

050616_0150_Howtoaccess6 How to access other ADF view object attributes using Groovy

govindan How to access other ADF view object attributes using Groovy
Connect me

Govind

Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

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 šŸ™‚
govindan How to access other ADF view object attributes using Groovy
Connect me
By | 2016-08-29T22:48:28+00:00 May 5th, 2016|Categories: ADF|Tags: , , , |1 Comment
  • Selvantharajah Roshanth

    It helps, Thanks

Like us on Facebook.
Connect!