Академический Документы
Профессиональный Документы
Культура Документы
This is based on a use case a customer had where they would get data
for a record in a table, if the row already exists in the table they need to
update it. If it doesn't exist they need to create a new row with the data.
The REST API provided by the Visual Builder business objects supports
this use case as long as you have the id of the record you want to
update. This is done with the upsert option for a POST call - see the
https://blogs.oracle.com/vbcs/service-methods-for-business-objects-in-visual-builder 1/5
9/1/2019 Service Methods for Business Objects in Visual Builder | Oracle Visual Builder Cloud Service Blog
But the data that the customer got didn't have the id of the record they
would need to update. Instead they had the information about another
field in the object. To resolve this we can create a function in the BO layer
that will search the set of records for a specific value in a specific field,
and then update that record if the value is found, or insert a record if it
doesn't exist.
https://blogs.oracle.com/vbcs/service-methods-for-business-objects-in-visual-builder 2/5
9/1/2019 Service Methods for Business Objects in Visual Builder | Oracle Visual Builder Cloud Service Blog
In the video below you'll see how to add such a function and how to call it
from the VB user interface. Note that these functions are also callable
from other tools through simple REST calls.
For those interested in the specific code used in the sample it is:
1 def vo = newView('Department')
2 vo.appendViewCriteria("department = '"+dname+"'")
3 vo.executeQuery()
4 if (!vo.hasNext()){
5 r = vo.createRow()
6 r.maxSalary=salary;
7 r.department=dname;
8 vo.insertRow(r)
9 }
10 while (vo.hasNext()) {
11 def r = vo.next();
12 r.maxSalary = salary;
13 }
https://blogs.oracle.com/vbcs/service-methods-for-business-objects-in-visual-builder 3/5
9/1/2019 Service Methods for Business Objects in Visual Builder | Oracle Visual Builder Cloud Service Blog
Line 2 adds a "where" clause to the query associated with our instance
In the while loop we handle the case where a record (or more) were
found, and update that row with the new value.
Comments ( 0 )
Recent Content
Site Map Legal Notices Terms of Use Privacy Cookie Preferences Ad Choices
https://blogs.oracle.com/vbcs/service-methods-for-business-objects-in-visual-builder 5/5