Oracle Fusion — Sandbox (Application Composer — Server Scripts — Groovy Scripting) — Part3

--

Greetings, Ardent Oracle Enthusiasts!

In this article, we’ll delve into the functionality of List of Values (LOV) for a field within Application Composer. This versatile tool equips us to precisely tailor customizations to address specific business requirements, aiding in the selection of accurate values for fields and minimizing errors.

Suppose you need to select a specific field from a “List of Values” (LOV) in the application composer. To accomplish this, you’ll have to generate a master custom object within the application composer, which will serve the purpose of the LOV in another Custom Objects (where you need the LOV).

We will now initiate the process of creating the Master Custom Object. Let’s take “Item Number” as an example.

Step1. Create the fields in Application Composer (Item Master):

Appl. Composer for Item Master
Appl. Composer Pages

Step2. Populate the Data:

You could either populate manually or using some script. In this case it’s been done through a button (which in turn calls a BIP Report through groovy script).

Step 2.1: Go to -> Server Scripts -> Object Functions

Object Function

Click to create a new Object fn.

Groovy Script to call a BIP report and set/update the fields of the appl. composer.

StringBuilder strMsg = new StringBuilder()
def userDetails=adf.util.getIntegrationUserDetails();
def userName=userDetails['username'];
def userPassword=userDetails['password'];
def reportRequest =
[
byPassCache :true,
flattenXML :false,
reportAbsolutePath :'/Custom/INVENTORY_ITEM.xdo',
sizeOfDataChunkDownload :-1,
]
def report = adf.webServices.PublicReportServiceN3.runReport(reportRequest,userName,userPassword);
def encoded = report.reportBytes;
def decoded = decodeBase64(encoded);
strMsg.append("\n reportRequest::"+reportRequest)
strMsg.append("\n reportData::"+decoded)
decoded=decoded.replaceAll('"','')
def vo1 = newView('ItemMaster_c')
decoded.eachLine {
line,
count ->
if (count > 0) {
// line ->
def(ITEM_NUMBER,INVENTORY_ORGANIZATION_ID,INVENTORY_ITEM_ID,MASTER_ORG_ID,RECORD_ID) = line.split('\\|')
try
{
if (ITEM_NUMBER != null)
{
strMsg.append("\n ITEM_NUMBER::"+ITEM_NUMBER)
vo1.reset();
def vc1 = vo1.createViewCriteria();
def vcr1 = vc1.createRow();
def vcr2 = vc1.createRow();
def vci1 = vcr1.ensureCriteriaItem('ItemInventoryItemId_c')
vci1.setOperator("=")
vci1.setValue(INVENTORY_ITEM_ID);
def vci2 = vcr2.ensureCriteriaItem('ItemInventoryOrganizationId_c')
vci2.setOperator("=")
vci2.setValue(INVENTORY_ORGANIZATION_ID);
vc1.insertRow(vcr1);
vcr1.setConjunction(1);
vc1.insertRow(vcr2);
vcr2.setConjunction(1);
vo1.appendViewCriteria(vc1);
vo1.executeQuery();
def itmExists ='notExists';
println("vo1.hasNext()=>"+vo1.hasNext()+ " ITEM_NUMBER" + ITEM_NUMBER);
strMsg.append("\n ITEM_NUMBER =>::"+vo1.hasNext())
if (vo1.hasNext())
{
def prow = vo1.next();
prow.setAttribute('RecordName',ITEM_NUMBER);
if (INVENTORY_ORGANIZATION_ID != null)
prow.setAttribute('ItemInventoryOrganizationId_c',INVENTORY_ORGANIZATION_ID);
if (INVENTORY_ITEM_ID != null)
prow.setAttribute('ItemInventoryItemId_c',INVENTORY_ITEM_ID);
if (MASTER_ORG_ID != null)
prow.setAttribute('JaqInvItemMasterOrgId_c',MASTER_ORG_ID);
itmExists ='Exists';
}
strMsg.append("\n ITEM NUMBER is Updated"+ITEM_NUMBER)
if (itmExists=='notExists')
{
println("New ItemCode=>"+ITEM_NUMBER );
strMsg.append("\n New ItemCode =>::"+ITEM_NUMBER)

def newRecord = vo1.createRow();
if (ITEM_NUMBER != null)
newRecord.setAttribute('RecordName',ITEM_NUMBER);
if (INVENTORY_ORGANIZATION_ID != null)
newRecord.setAttribute('JaqInvItemInventoryOrganizationId_c',INVENTORY_ORGANIZATION_ID);
if (INVENTORY_ITEM_ID != null)
newRecord.setAttribute('JaqInvItemInventoryItemId_c',INVENTORY_ITEM_ID);
if (MASTER_ORG_ID != null)
newRecord.setAttribute('JaqInvItemMasterOrgId_c',MASTER_ORG_ID);

vo1.insertRow(newRecord);
strMsg.append("\n ITEM NUMBER is Inserted"+ITEM_NUMBER)
}
}
}
catch (e)
{
println("Error in Populating Error in Item Number=>"+ITEM_NUMBER+ " Error=>"+e );
}
}
}
return strMsg;

Step3. Create a Button:

Go to Actions and Links -> Click to add a new Action

Actions and Links for Button

Step4. Create Re-usable Page:

To enable searching for results in other custom objects based on a Master Object, we must create Re-Usable Regions within the Page. These regions will facilitate both the search functionality and the display of search results. For example, they will allow users to search for a specific item and showcase the manner in which the results are presented.

Re-Usable Page
Define the Search Region
Serach Region and Search Results

Step5. Create a new Object:

Now, you need to create new custom object and while creating the new field, select the Choice List (Dynamic)

Choice List (Dynamic)
Searchable Object

Step6. Search for the new item from the custom Object

Go to Newly craeted custom object and search for the item.

Thus, in this way the approach enables the creation and validation of the LOV against the master field.

For Other application composer blogs, please refer:

Oracle Fusion — Sandbox (Application Composer — Basic Concepts and creation of Objects) — Part1 | by Samir Jha — OCI |OIC |Oracle Fusion SaaS Technical | Medium

Oracle Fusion — Sandbox (Application Composer — Server Scripts — Groovy Scripting) — Part2 | by Samir Jha - OCI |OIC |Oracle Fusion SaaS Technical | Medium

Regards,

Samir

--

--

Samir Jha - OCI |OIC |Oracle Fusion SaaS Technical

Samir brings over 14 years of experience as an Oracle Fusion Solution Architect, specializing in SCP, SCM, and Financial domains.