Overview

When pricing an opportunity in PrecisionLender, application events are sent to Andi® to notify her of changes to the opportunity. The opportunityModel powers allow you to access the opportunityModel for an application event. 

 

In this Article

 
 

What is the opportunityModel?

The opportunityModel is the JSON object that contains opportunity specific data when an application event occurs. The object contains the following shape:

OpportunityModel {
contextId: string;
engineModel: EngineModel{};
opportunityDetails: OpportunityDetails{};
accountChanges: AccountChange[];
scenario:{};
productFamilyId: string;
productId: string;
}

Not all model properties will appear in the data for every event. For model properties available for each application event, see PrecisionLender Application Events.

 

What are the opportunityModel powers?

The opportuntityModel powers allow you to view and access the JSON object, and the object and arrays of the properties within the opportunityModel.
 
The available opportunityModel powers are:
  • getCurrentOpportunityModel - this method is a promise that provides access to return opportunityModel data as events occur while a user edits an opportunity.
  • getSavedOpportunityModel - this method is a promise that provides access to return opportunityModel data from when an opportunity was last saved.

 

When to use the opportunityModel powers

You should use the getCurrentOpportunityModel when writing a skill that needs to access real time data, such as a field tag that provides information from the financial statement while the user is editing an opportunity. 

You should use the getSavedOpportunityModel when writing a skill that doesn't need access to real time data. This is best used in situations where skills, such as email notifications, are used to provide updates about an opportunity outside of the application when an opportunity isn't being edited and using the last, best known information.

 

How to call the opportunityModel powers

The opportunityModel powers will be called via the opportunity property of the PrecisionLender context. 
 
skillContext.powers.precisionLender.opportunity.yourChosenModelPower()
 
To access the data within the opportunityModel and have the ability to use intellisense, you'll need to return the promise. As an example:
//Example 1
return skillContext.powers.precisionLender.opportunity
.getCurrentOpportunityModel()
.then((opportunityModel) => {
// For this example skill we will just take the first loan account
return opportunityModel.engineModel.commercialLoanAccounts[0];
})

//Example 2 return skillContext.powers.precisionLender.opportunity
.getCurrentOpportunityModel()
.then((opportunityModel) => {
let commercialLoanAccounts = opportunityModel.engineModel.commercialLoanAccounts;
if(!commercialLoanAccounts) return 0;
 
 
 
Was this article helpful?
1 out of 1 found this helpful