Published Objects Accessible to Child/Client Application

The following published objects are accessible to Child/Client application:

  • tpoApplication
  • auth
  • loan

Methods Available in tpoApplication Object

There are several methods available in the tpoApplication Object. These methods provide access to the currently logged in user, exposes the user’s Company information, and enable hosted pages to perform redirects back to standard Encompass TPO Connect pages.

  • getUserData exposes limited information about the user.
/* 
* name: getUserData 
* parameters: none 
* returns: promise 
* resolves to object: { 
userFullName - user full name 
email - email address, 
contactID - contact id 
externalOrgID - TPO external organization id 
roles - user roles 
personas - user personas } 
*/ 
tpoAppObject.getUserData().then(function(userSummary) { 
  console.log('User data ===', userSummary); 
});
  • getUserProfileData provides complete information about the user.
/* 
* name: getUserProfileData 
* parameters: none 
* returns: promise 
* resolves to object: Complete User Profile Object 
*/ 
tpoAppObject.getUserProfileData().then(function(userProfile) {
  console.log('User profile data ===', userProfile); 
});
  • getExternalOrgDetails exposes a user’s Company information.
/* 
* name: getExternalOrgDetails 
* parameters: none 
* returns: promise 
* resolves to object: {
			“siteId”: “4897532730”, 
			“companyOrgId”: “167”, 
			“companyExternalOrgId”: “6514705893”, 
			“companyName”: “TPOTestOrg”, 
			“branchOrgId”: <branch name>, 
			“branchExternalId”: <branch external id>, 
			“branchName”: “TPOBranchOrg”, 
}
		Note: branchOrgId, branchExternalId, branchName properties will be available if the logged in user is from a TPO Branch 
*/ 
tpoAppObject.getExternalOrgDetails().then(function(externalOrgData) {
      console.log('External Org data ===', externalOrgData);
});
  • pageRedirect redirects to a page in the TPO Application.
/* 
* name: pageRedirect 
* parameters: <pageName>, <loanId> 
* returns: promise 
* resolves to object: none 
*/ 

tpoAppObject.pageRedirect ('Loan Summary', {id: <loanGuid>});

Deprecated Methods

The following methods have been deprecated for the tpoApplication Object. Please use the suggested replacement as noted below.

DeprecatedUse Instead
getLoanSummaryLoan object
getLoanDataLoan object
createAuthCodeAuth object
  • getLoanSummary (Deprecated)
/* This method is deprecated and will be removed in future release. 
Use loan object instead.
* name: getLoanSummary
* parameters: none 
* returns: promise 
* resolves to object: { 
				loanId - loan GUID 
        loanNumber - loan number 
        loanType - mortgage type 
        loanPurpose - loan purpose 
        channel - loan channel 
        createdDate - loan created date 
        }
*/
tpoAppObject.getLoanSummary().then(function(loanSummary) {
	console.log('Loan Summary ===', loanSummary); 
  });
  • getLoanData (Deprecated)
/* This method is deprecated and will be removed in future release. 
Use loan object instead.  
  * name: getLoanData 
  * parameters: none 
  * returns: promise 
  * resolves to object: Complete Loan Data Object 
*/ 
tpoAppObject.getLoanData().then(function(loanData) { 
  console.log('User profile data ===', loanData); 
});
  • createAuthCode (Deprecated for the tpoApplication )
/* This method is deprecated and will be removed in future release. 
Use auth object instead. 
* name: createAuthCode 
* parameters: TPO Client ID (‘3c5hwwa8’) 
* returns: promise 
* resolves to string: authCode // e.g. _6Z2ZVKm_1rlSvDqqU99b4Q6yWG3me_2UfVJffhg 
*/ 
tpoAppObject.createAuthCode(‘3c5hwwa8’, 1) 

/* Refer to sample code for actual implementation */

Methods Available in auth Object

There are two methods available in the auth Object. These methods generate a new auth code and access to the currently logged in user.

  • createAuthCode generates a new auth code.
/* 
* name: createAuthCode 
* parameters: TPO Client ID (‘3c5hwwa8’) 
* returns: promise 
* resolves to string: authCode // e.g. _6Z2ZVKm_1rlSvDqqU99b4Q6yWG3me_2UfVJffhg 
*/ 
tpoAuthObject.createAuthCode(‘3c5hwwa8’) 

/* Refer to sample code for actual implementation */
  • getUser exposes limited information about the user.
/* 
* name: getUser 
* parameters: none 
* returns: promise 
* resolves to Object: { 
					“id”: <user id>, 
          “realm”: <encompass instance id>,
          “firstName”: <user first name>, 
          “lastName”: <user last name> 
    } 
*/ 

		tpoAuthObject.getUser().then(function(userData) { 
      	console.log('User data ===', userData); 
    });

Methods Available in loan Object

There are several methods available in the loan Object. These methods provide a complete loan data object, indicates if a loan is read-only, provides a calculated loan data object, and notifies the parent application to fetch and apply changes with updated loan data.

  • all provides a complete loan data object.
/* 
* name: all 
* parameters: none 
* returns: promise 
* resolves to Object: {
		"id": "7087e633-f215-4d56-9f7c-02d97c7c8049", 
    "loanIdNumber": "100200100349", 
    "applications": [...], 
    . 
    . 
    . 
} 
*/

tpoLoanObject.all().then(function(loanData) {
  console.log('Loan data ===', loanData); 
});
  • isReadOnly is a Boolean flag that indicates if the loan is in read only mode.
/* 
* name: isReadOnly 
* parameters: none 
* returns: promise 
* resolves to: boolean 
*/ 

tpoLoanObject. isReadOnly().then(function(isReadonlyFlag) {
  console.log('Is Read Only Loan ===', isReadonlyFlag);
});
  • calculate provides a calculated loan data object.
/* 
* name: calculate 
* parameters: none 
* returns: promise 
* resolves to Object: {
		"id": "7087e633-f215-4d56-9f7c-02d97c7c8049", 
    "loanIdNumber": "100200100349", 
    "applications": [...],
    . 
    . 
    .
 } 
 */ 

tpoLoanObject.calculate().then(function(loanData) {
  console.log('Calculated Loan data ===', loanData); 
});
  • merge notifies the parent application to fetch and apply changes with updated loan data.

📘

Important Note

It is important to perform a merge on the loan object to ensure the local (workspace) loan is refreshed with changes made directly in Encompass. For example, perform a merge operation before the client/child application is closed and the user is returned to the parent (TPO) application.

/* 
* name: merge 
* parameters: none 
* returns: promise 
* resolves to Object: {
		"id": "7087e633-f215-4d56-9f7c-02d97c7c8049", 
    "loanIdNumber": "100200100349", 
    "applications": [...], 
    . 
    . 
    . 
 } 
 */

tpoLoanObject.merge().then(function(loanData) {
  console.log('Response after merge ===', loanData); });

Sample Code and Usage Notes for the pageRedirect

To navigate to standard pages/loan actions:

await  redirect.pageRedirect('PAGE NAME HERE', {
    id: 'LOAN GUID HERE',
    });

Standard Pages (case sensitive):

• Loan Summary
• Product Pricing & Lock
• Loan Estimate Fee Management
• Documents
• Conditions
• Enhanced Conditions
• Service Orders
• esign
• Purchase Advice
• Fees
• Disclosure Tracking
• Import Additional Data
• DUAL AUS
• Order Credit
• Order DU
• Order LPA
• Disclosures
• Submit Loan
• Re-Submit Loan
• Withdraw Loan
• Change of circumstance

To navigate to any sub section under URLA 2020:

To navigate to any specific sub-section, you will need to pass one additional parameter named "section”.

await redirect.pageRedirect('urla', {
    id: 'LOAN GUID HERE',
    section: 'URLA SECTION NAME HERE'
    });

📘

Important Note

Custom widgets are not supported.

Section Parameter Values (case sensitive):

• Additional Information
• Lender Loan Information
• Borrower Information
• Loan and Property Information
• Assets and Liabilities
• Real Estate
• Employment and Income
• Information for Government Monitoring
• URLA Continuation

📘

Important Note

When navigating to URLA 2020, if the selected section is "hidden" in TPO Admin URLA 2020 settings, the user will stay on the same SSF page (i.e., navigation will not occur).

Sample Code for TPOC Page Redirect

async function redirect(pageName) {
    if (pageName.startsWith("URLA:")) {
        var section = pageName.split(':')[1];
        await tpoAppObject.pageRedirect('urla', {
            id: this.loanId,
            section: section
        });
    } else {
        await tpoAppObject.pageRedirect(pageName, {id: this.loanId });
    }
}
<select id="redirect" onchange="redirect(this.value);" style="width: 100%;">
    <option value="">Quick Links</option>
    <option value="Welcome">Welcome</option>
    <option value="Loan Summary">Loan Summary</option>
    <option value="URLA:Additional Information">URLA: Additional Info</option>
    <option value="URLA:Lender Loan Information">URLA: Lender Loan Info</option>
    <option value="URLA:Borrower Information">URLA: Borrower Information</option>
    <option value="URLA:Loan and Property Information">URLA: Loan & Property</option>
    <option value="URLA:Assets and Liabilities">URLA: Assets and Liabilities</option>
    <option value="URLA:Real Estate">URLA: Real Estate</option>
    <option value="URLA:Employment and Income">URLA: Employment & Income</option>
    <option value="URLA:Information for Government Monitoring">URLA: Government Monitoring</option>
    <option value="URLA:URLA Continuation">URLA: Continuation</option>
    <option value="Product Pricing & Lock">Product Pricing & Lock</option>
    <option value="Loan Estimate Fee Management">Loan Estimate Fee Management</option>
    <option value="Generate Disclosures">Generate Disclosures</option>
    <option value="Service Orders">Service Orders</option>
    <option value="Documents">Documents</option>
    <option value="Conditions">Conditions</option>
    <option value="Enhanced Conditions">Enhanced Conditions</option>
    <option value="esign">eSign</option>
    <option value="Purchase Advice">Purchase Advice</option>
    <option value="Fees">Fees</option>
    <option value="Disclosure Tracking">Disclosure Tracking</option>
    <option value="Import Additional Data">Import Additional Data</option>
    <option value="DUAL AUS">Dual AUS</option>
    <option value="Order Credit">Order Credit</option>
    <option value="Order DU">Order DU</option>
    <option value="Order LPA">Order LPA</option>
    <option value="Submit Loan">Submit Loan</option>
    <option value="Re-Submit Loan">Re-Submit Loan</option>
    <option value="Withdraw Loan">Withdraw Loan</option>
    <option value="Change of circumstance">Change of circumstance</option>
</select>

Sample Code Generating an Auth Token and then Retrieving User Data

/* Sample Implementation Code to demonstrate...
* 1. Getting AuthCode from Parent Application (TPO Connect)
* 2. Exchanging AuthCode to AccessToken
* 3. Introspection call to get logged in User’s Token Information
* 4. Making API Calls using AccessTken to get User Details
*/

import axios from 'axios'; // for making HTTP Request

var authObject = null;
// Get auth object from parent application elli.script.getObject(‘auth’).then(function(authObject) 
{
authObject = authObject; // cache auth object
})

/* 1. Get AuthCode from Parent Application (TPO Connect) */ function createCode() {
return authObject.createAuthCode('3c5hwwa8').then((authCode) => {
// e.g. authCode -> _6Z2ZVKm_1rlSvDqqU99b4Q6yWG3me_2UfVJffhg return getAccessToken(authCode);
});
}

/* 2. Exchanging AuthCode to AccessToken
This call can be moved to Server Side to avoid exposing client id/secret
*/
function getAccessToken(authCode) {
const jsonData = `grant_type=authorization_code&code=${authCode}`;
let req = {
method: 'POST',
url: 'https://api.elliemae.com/oauth2/v1/token', data: jsonData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic
eDlpeGazczpeUkVISmY4b2hbSDFmN2dCTVM4OUptKkZJYwY3b2ZSNk0jVm02IWVeYjNsODddhxS1drJDVycCRZUlp2bzNpOX 
Ja'
}
 };
 return axios(req).then(handleResponse);
}
/* Reading access token and setting in HTTP headers for further API Calls*/
function handleResponse(response) { let data = response.data;
/* data -> {
"access_token": "J2iccrnezBhUxzCN3z3DVlJfOvYt", "scope": "tpoc",
"token_type": "Bearer"
} */
if (response.status !== 200) {
const error = (data && data.message) || response.statusText; throw new Error(error);
}
let {token_type: tokenType, access_token: accessToken} = data; return 
userIntrospection(accessToken).then((res) => {
// Set AccessToken to HTTP Request headers axios.defaults.headers.common['Authorization'] = 
`${tokenType} ${accessToken}`; return getUserDetails(res.data.user_name);
});
}

/* 3. Introspection call to get logged in User’s Token Information */
function userIntrospection(token) { const jsonData = `token=${token}`; let req = {
method: 'POST',
url: 'https://api.elliemae.com/oauth2/v1/token/introspection', data: jsonData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic
eDlpeGazczpeUkVISmY4b2hbSDFmN2dCTVM4OUptKkZJYwY3b2ZSNk0jVm02IWVeYjNsODddhxS1drJDVycCRZUlp2bzNpOX 
Ja'
}
};
return axios(req);
}
/* Reading access token and setting in HTTP headers for further API Calls*/
function handleResponse(response) { let data = response.data;
/* data -> {
"access_token": "J2iccrnezBhUxzCN3z3DVlJfOvYt", "scope": "tpoc",
"token_type": "Bearer"
} */
if (response.status !== 200) {
const error = (data && data.message) || response.statusText; throw new Error(error);
}
let {token_type: tokenType, access_token: accessToken} = data; return 
userIntrospection(accessToken).then((res) => {
// Set AccessToken to HTTP Request headers axios.defaults.headers.common['Authorization'] = 
`${tokenType} ${accessToken}`; return getUserDetails(res.data.user_name);
});
}
/* 3. Introspection call to get logged in User’s Token Information */
function userIntrospection(token) { const jsonData = `token=${token}`; let req = {
method: 'POST',
url: 'https://api.elliemae.com/oauth2/v1/token/introspection', data: jsonData,
headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic
eDlpeGazczpeUkVISmY4b2hbSDFmN2dCTVM4OUptKkZJYwY3b2ZSNk0jVm02IWVeYjNsODddhxS1drJDVycCRZUlp2bzNpOX 
Ja'
}
};
return axios(req);
}

/* 4. Get User Details */
function getUserDetails(userId) { let req = {
method: 'GET',
url: `https://api.elliemae.com/encompass/v1/users/${userId}`
};
return axios(req).then((response) => { user = response.data;
return user;
});
}

For additional information and examples of the server-side token exchange service, see the following resources: