The Visual Builder Cloud Service Blog

Creating & Invoking Business Object Functions from Visual Builder UI

Shay Shmeltzer
Director of Product Management - Oracle

The business object layer in Visual Builder allows you to add business logic that can implement functionality on your data layer. In this blog we are going to show you how to use such a function to iterate over a set of records in a parent/child relationship, and update a set of records in a single REST call, as well as how to invoke that function from your visual builder UI. It's worth mentioning here that these functions can also be invoked from other applications that need access to your business services.

Our example is a master/detail Departments/Employees scenario, where we want to build an interface that will let us update the salary of all the employees in a specific department with a bonus increase. While you can do this by calling a REST Patch operation on each employee independently, a more efficient way to do this would be to expose a single function that can update all the employees.

Business Object Functions come to the rescue. We are going to define an object function that can be invoked on a specific department, accepts the bonus as a parameter, and then loops over all the employees working in this department and updates their salary with the new bonus.

The groovy code for such a function is:

def collection1 = Employees;
while (collection1.hasNext()) {
  def record1 = collection1.next();

Note that the "Employees" in the first row is the name of the accessor that connects the two objects. In the video we show you how to define this accessor through the business object diagram in Visual Builder.

We can mark this function to be "callable from external system" - which will then expose a REST endpoint on our business objects that will allow you to invoke the function from the Visual Builder pages (or other external systems). Now we are just left with the task of creating the UI to invoke this POST endpoint, passing in the needed parameters. Important note - if you want to invoke this function from outside VB you need to set the Content-Type header to application/vnd.oracle.adf.action+json .

In the video below you can see how to:

  • Create a master/detail UI - fetching employees for a specific department
  • Add an accessor to a relationship between objects (to allow access to the employees from a specific department)
  • Add an object function, provide parameters, and use code templates to loop over children
  • Add an action chain that calls the REST POST endpoint passing in the parameters to the method

Join the discussion

Comments ( 1 )
  • Jonerechal Thursday, April 29, 2021
    Simply wish to say your article is as astonishing. The clarity in your post is simply great, and I could assume you are an expert on this subject. Same as your blog i found another one Oracle Project Portfolio Management Cloud Software .Actually I was looking for the same information on internet for Oracle PPM and came across your blog. I am impressed by the information that you have on this blog. Thanks a million and please keep up the gratifying work.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.