- Ensure Oracle Cloud Functions is installed and that you can deploy a simple Java-based Oracle Cloud Function. If you haven't already installed and configured Oracle Cloud Functions then we can recommend going through the Oracle Cloud Functions quickstart tutorial as this will not only help you setup and configure your environment but also show you how to deploy some sample Oracle Cloud Functions to OCI.
- Ensure you have access to Oracle Vault and Oracle Object Storage in your Oracle Cloud Infrastructure (OCI) compartment
- Ensure you have access to Oracle Sales Cloud and have all necessary permissions to access the application composer tool.
If you haven't already provisioned and configured an Oracle Autonomous JSON Database, you can follow the steps in the Provision Autonomous JSON Database guide to provision a JSON database.
Once the database is provisioned, you need to download the Oracle client credentials (wallet files) from the Autonomous Database details page. You can follow the instruction in Download Client Credentials (Wallets).
Before you can deploy a serverless function, you need to make sure the Oracle Functions is configured and verified for deployment, you can follow the instructions in Oracle Functions Quick Start Guides to prepare your environment for deployment.
To deploy the serverless function for this sample solution:
-
Clone the sample code from this repository.
-
This sample will use SOADA for Java to connect the Oracle Autonomous JSON Database. You need to create a
lib
folder in the<repo>/customerview-fn
folder, e,g,<repo>/customerview-fn/lib
and downloadorajsoda-1.1.7.jar
from this link and save it to thelib
folder. -
Run the following command to create the Oracle Cloud Functions application in OCI, ensure you pass a valid existing subnet from your networking configuration. This would have been created as part of the Oracle Cloud Functions quickstart tutorial but you are free to use any public subnet within your OCI infrastructure.
fn create app customerview --annotation oracle.com/oci/subnetIds='["<subnet-ocid>"]'
-
Login to the OCI console and create an Object Storage folder with the bucket name "JSONDBWallet".
-
Unzip the downloaded Oracle client credentials (wallet files) zip file for the Oracle Autonomous JSON Database to a temp folder, then upload all files to the object storage bucket (JSONDBWallet)
-
Create a OCI Vault in your tenancy, this is used to store the DB Secret and your SMTP server password. Once the vault is created note down the OCID for both secrets (DB Secret and SMTP server password) as you you need it in step #9. If needed please see the OCI Vault documentation on how to create an OCI Vault and its related secrets.
-
Run the following commands to create configuration parameters within the Oracle Cloud Functions application. replace the appropriate values with your system specific values, e.g. the DB Password secret OCID which was created earlier. These values can also be added using the OCI console.
fn config app customerview DB_URL jdbc:oracle:thin:\@customerviewdb_high\?TNS_ADMIN=/tmp/wallet fn config app customerview DB_USER Admin fn config app customerview NAMESPACE <namespace> fn config app customerview BUCKET_NAME <JSONDBWallet> fn config app customerview EMAIL_SECRET_OCID <email vault ocid> fn config app customerview DB_SECRET_OCID <db vault ocid> fn config app customerview SMTP_SERVER <smtp.server.com> fn config app customerview SMTP_USER <smtp userid> fn config app customerview SMTP_SERVER_PORT <smtp port> fn config app customerview OCI_REGION <oci region for object storage and vault> fn config app customerview WALLET_DIR /tmp
-
Go to the repository
<repo>/customerview-fn
folder and run the following command to deploy the serverless function. This command deploys the customerview Java based Oracle Cloud Function to OCI.
fn -v deploy --app customerview
You need to create and configure the API Gateway to process and route the traffic from the Oracle Sales and the VB application to the serverless function. Follow the instructions describe in Creating an API Gateway and the data points below to create the API gateway and add routes to the serverless function deployed in the previous step.
API Gateway Configuration:
Name: Customer360-Gateway
Type: Public
Compartment: select your compartment
VCN: select your VCN
Subnet: select the public subnet in your VCN
Deployment:
Name: Customer360
Path Prefix: /customer360
Route 1:
Path : /loan
Methods: GET, Post
Type: Oracle Functions
Select the function deployed for this sample: e.g. customerview
Function name: customerview-fn
Route 2:
Path : /verify
Methods: GET
Type: Oracle Functions
Select the function deployed for this sample: e.g. customerview
Function name: customerview-fn
We also need to make sure the REST calls between Oracle Sales/VB application and the serverless function are secured. You can refer to this blog article to configure using OAuth to secure the serverless function with API Gateway and Oracle Identitity Cloud Service (IDCS). This blog article describes how to secure a BICC webservice, in this sample we'll be securing out a serverless function. So, you can follow the Configuration of an API Gateway Deployment and Setup a Custom App in IDCS section of this article. However, instead of configuring the API Gateway pointing to the BICC NodeJS webservice, we'll point it to our serverless function.
This sample solution contains an Oracle Visual Builder(VB) application that displays the data retrieved from the database. You need to deploy the VB application and configure the service connection endpoints created for this sample solution.
- Go to the '
<repo>/VB/src
folder, you will notice there 1 VB src folder: customerview-1.0, zip this folder to create a deployment zip file, e.g. customerview-1.0.zip - Sign in to the VB instance.
- Import the VBS application using the zip file.
- Open the VB application, for each service, go to services->servers, edit the server to configure the authentication if required, test and save the sample response data.
This sample solution require number of custom objects with child object. Use the information in this section to create the custom objects, web services, and object workflows in the Application Composer. If you are not familiar with using Application Composer in Oracle Sales, you can refer to Configuring Applications Using Application Composer on how to add objects and fields, create object workflows and using groovy scripting etc.
Login to the Oracle Sales Cloud, create a sandbox with Application Composer support and then configure the following custom objects and child objects:
API_Name: Assets_c
Fields:
Name | Field Type | Default Value |
---|---|---|
Type | Text | Assets |
OptyId | Text |
Child Objects:
Name: Account
API Name: Account_c
Fields:
Name | Field Type |
---|---|
Balance | Currency |
FinancialInstitutionName | Text |
Name: HomeAndInvestmentProperties
API Name: HomeAndInvestmentProperties_c
Fields:
Name | Field Type |
---|---|
PresentValue | Currency |
Address | Text |
Name: MotorVehicles
API Name: MotorVehicles_c
Fields:
Name | Field Type |
---|---|
PresentValue | Currency |
Make | Text |
Model | Text |
YearOfManufacture | Text |
Name: OtherAssets
API Name: OtherAssets_c
Fields:
Name | Field Type |
---|---|
PresentValue | Currency |
Description | Text |
API_Name : LoanApplicantIncome_c
Name | Field Type | Default Value |
---|---|---|
Type | Text | Income |
OptyId | Text |
Child Objects:
Name: OtherIncome
API Name: OtherIncome_c
Fields:
Name | Field Type |
---|---|
AfterTaxAmount | Currency |
GrossAmount | Currency |
OtherIncomeType | Text |
Name: Salary
API Name: Salary_c
Fields:
Name | Field Type |
---|---|
AfterTaxSalary | Currency |
GrossSalary | Currency |
Applicant | Text |
API_Name : LoanApplicantLiabilities_c
Fields:
Name | Field Type | Default Value |
---|---|---|
Type | Text | Liabilities |
OptyId | Text |
Child Objects:
Name: CreditAndStoreCard
API Name: CreditAndStoreCard_c
Fields:
Name | Field Type |
---|---|
AmountOwing | Currency |
CreditLimit | Currency |
Borrower | Text |
CardType | Text |
FinancialInstitutionName | Text |
Name: HomeAndInvestmentPropertyLoa
API Name: HomeAndInvestmentPropertyLoa_c
Fields:
Name | Field Type |
---|---|
AmountOwing | Currency |
OriginalLoanAmount | Currency |
Borrower | Text |
PropertyType | Text |
FinancialInstitutionName | Text |
Name: OtherLoan
API Name: OtherLoan_c
Fields:
Name | Field Type |
---|---|
AmountOwing | Currency |
CurrentLimitOrOriginalLoanAmount | Currency |
Borrower | Text |
Purpose | Text |
FinancialInstitutionName | Text |
Name: PersonalLoan
API Name: PersonalLoan_c
Fields:
Name | Field Type |
---|---|
AmountOwing | Currency |
CurrentLimitOrOriginalLoanAmount | Currency |
Borrower | Text |
Purpose | Text |
FinancialInstitutionName | Text |
When the event is triggered in Oracle Sales, the workflow will invoke the REST services you deployed in Oracle Functions. So before you can configure the Object Workflow in Oracle Sales, you need to create the following web services in Application Composer:
- Retrieve the object data using the Id:
- Name:
LoanDataService
- URL:
https://<ocs_host>:443/crmRestApi/resources/latest/##object##/##key##
- Authentication Scheme:
Call using IDCS OAUTH
- Client Credential Key: Give the key a name
- Token URI:
https://<idcshostname>/oauth2/v1/token
- Scope :
This will be the same as the resource that was added to the IDCS client application when you configure the IDCS for the API Gateway
- Subject Precedence :
Unchecked
- Credential Key for Switch Identity:
Enter/Create the Credential Key (Please note that the user defined in the key must also exist in both IDCS and Oracle Sales. The user's password in the Credential Key is the Oracle Sales user password, not the IDCS password)
- Method:
GET
- Format:
JSON
- Request Payload Code Sample:
{}
- Response Payload Code Sample:
{}
- Name:
- Post data to Fn via API Gateway
- Name:
CustomerViewService
- URL :
https://FN-API-Gateway-URL
- Authentication Scheme:
Call using IDCS OAUTH
- Client Credential Key: Give the key a name
- Token URI:
https://<idcshostname>/oauth2/v1/token
- Scope :
This will be the same as the resource that was added to the IDCS client application when you configure the IDCS for the API Gateway
- Subject Precedence :
Unchecked
- Credential Key for Switch Identity :
Enter/Create the Credential Key (Please note that the user defined in the key must also exist in both IDCS and Oracle Sales. The user's password in the Credential Key is the Oracle Sales user password, not the IDCS password)
- Method:
POST
- Format:
XML
- Request Payload Code Sample:
<?xml version = '1.0' encoding = 'UTF-8'?><LoanData/>
- Response Payload Code Sample:
<?xml version = '1.0' encoding = 'UTF-8'?><LoanData/>
- Name:
Object workflow in Oracle Sales is another key part of this sample solution. It defines the process of when and how to send the data, and what data you want to send to the serverless function you've deployed for this sample solution. To create object workflow for the custom objects above and the opportunity object with Groovy script action.
Event point: When a record is updated
- Condition:
if (isAttributeChanged('LastUpdateDate')) return true;
- Execution Schedule:
0 Days After LastUpdateDate
Event point: When a record is created
- Condition:
if (isAttributeChanged('CreationDate')) return true;
- Execution Schedule:
0 Days After CreationDate
The sample groovy scripts can be found in the scripts folder:
Import a Visual Application
Engagement Cloud - Outbound REST Using IDCS OAUTH
Object Workflows