Groovy Script for Calling Interviews From Actions In Fusion

When you are adding an Intelligent Advisor interview as an action (that is, to an action menu item or a button) in Fusion classic interfaces, you need to specify the groovy script to call the interview.

Note: When you are adding an Intelligent Advisor interview to a subtab, you only need to specify the groovy script to call the interview if you are using (Release 13 update 19D or earlier), or if you are using checkpoints.

Groovy script

The groovy script is:

def policyModel = <policy_model> ; // Name of the deployed Intelligent Advisor interview
def databaseId  = <databaseId> ;  // Unique database identifier of the top level Fusion object

def jwtToken=new oracle.apps.fnd.applcore.common.SecuredTokenBean().getTrustToken();
def userName = adf.context.getSecurityContext()?.getUserName();
oracle.topologyManager.client.deployedInfo.DeployedInfoProvider.getEndPoint('OPA_HUB_URL')+"/web-determinations/startsession/<policy_model>?SurveyCaseId="+<database_id>+"&opauniqueuser=${userName}&jwt="+jwtToken+"";

Groovy script for interviews using checkpoints

If you want to enable agents to resume the Intelligent Advisor interview from a previously saved checkpoint, then the groovy script is:

def objectName  = <object_name> ; // Name of the top level Fusion object
def policyModel = <policy_model> ; // Name of the deployed Intelligent Advisor interview
def databaseId  = <databaseId> ;  // Unique database identifier of the top level Fusion object
 
def jwtToken = new oracle.apps.fnd.applcore.common.SecuredTokenBean().getTrustToken();
def isResumable = oracle.apps.fod.industry.common.salesPolicyConnector.salesPolicyConnectorService.impl.CheckpointTool.isResumable(databaseId, objectName,policyModel);
def userName = adf.context.getSecurityContext()?.getUserName();
def urlSuffix = "/policyModel?SurveyCaseId="+ databaseId + "&ObjectName=" + objectName + "&PolicyModel="+ policyModel +"&opauniqueuser=${userName}" + "&jwt=" +jwtToken;
def urlPrefix = oracle.topologyManager.client.deployedInfo.DeployedInfoProvider.getEndPoint('OPA_HUB_URL')+ "/web-determinations";
 
if(isResumable)
{
    return urlPrefix+"/resumesession"+urlSuffix;
}
else
{
    return urlPrefix+"/startsession"+urlSuffix;
}

Note that in these scripts:

  • There are no spaces in object names. See Objects Supported for Oracle Fusion for the object name to use in the groovy script.

  • The userName variable uses string interpolation (that is, the string has a placeholder referencing the variable). The placeholder expression is surrounded by ${} like this: ${userName}. Alternatively, the variable can be included in the string using simple string concatenation like this: +username+ (in the same way that the OptyId is used in the groovy script examples shown).

Database identifiers for common objects are:

  • ActivityId for the Activity object
  • LeadId for the Lead object
  • OptyId for the Opportunity object
  • PartyId for the Account object, Contact object, Partner object and Household object
  • SrId for the Service Request object

For more information on writing groovy script, see: