How can I display explanations for Machine Learning predictions as a drawer in Oracle Sales?

You can display explanations for machine learning predictions as a drawer in Oracle Sales by:

  1. Creating a virtual field, which is a field that's generated dynamically and doesn't physically exist in the database.
  2. Exposing it as a linked field, which when clicked, will open a drawer to display prediction explanations.

Explanations of machine learning predictions provides salespeople with added insight into the highest impacting factors that can help their sales organization improve sales efficiency and productivity. For example, salespeople can take appropriate actions to mitigate any outcomes that negatively impact the prediction. They can also use the insights from positive factors to devise a sales strategy that plays to their unique strengths.

Create a Virtual Field Using Visual Builder Studio (VBS)

Here's an example that shows how to create a virtual field for the Leads object:

  1. Open Oracle Visual Builder Studio.
  2. Click the Layouts tab and select Leads > Fields.
  3. Click Create Field and because this field is expected to be a link, ensure that it follows the format as highlighted in the Type field as shown:

    Sample screenshot highlighting the options to create a virtual field type

    For example, enter the following details:
    • Label: PredictedLeadScore
    • ID: predictedLeadScore
    • Type: Select Object (Virtual Field) from the drop-down list.
  4. Click Create.

After creating the virtual field, you must manually edit its configuration to include the following attributes:

  • labelHint
  • value
  • displayField
  • primaryKey
  • selfLinkKey
  • mode
  • referencedFields
  1. Click the JSON tab as shown:

    Screenshot showing the JSON attribute details for the virtual field type

  2. Find the virtual field entry created in the previous task.
  3. Change the JSON to include the required attributes

Here are sample configurations for the Opportunity Predicted Win Probability and Lead Scoring predefined models. These examples assume that:

  • The Predicted Win Probability model uses the PredWinProb attribute in the Opportunity object.
  • The Lead Scoring model uses the AILeadScore attribute in the Lead object.

Sample Code Snippet for: Opportunity PredWinProb Model

"PredictedWinProb": {
  "type": "object",
  "labelHint": "[[$fields.PredWinProb.metadata.labelHint]]",
  "value" : "[[ $fields.PredWinProb.value ]]",
  "properties": {
    "resource": {
      "value": "opportunities"
    },
    "displayField": {
      "attribute": "PredWinProb",
      "value": "{{ $fields.PredWinProb.value }}",
      "metadata": "[[ $fields.PredWinProb.metadata ]]"
    },
    "primaryKey": {
      "attribute": "OptyId",
      "value": "{{ $fields.OptyId.value }}",
      "metadata": "[[ $fields.OptyId.metadata ]]"
    },
    "selfLinkKey": {
      "attribute": "OptyNumber",
      "value": "{{ $fields.OptyNumber.value }}",
      "metadata": "[[ $fields.OptyNumber.metadata ]]"
    },
    "mode": {
      "value" : "drawer"
    },
    "context" : {
      "value" : "[[ {'feature': 'salesmlprediction', 
       'usecasecode' : 'CX_OPPORTUNITY_WIN_PROBABILITY', 
       'title': $fields.Name.value()} ]]"
    }
  },
  "referencedFields": [
    "Name",
    "OptyId",
    "OptyNumber",
    "PredWinProb",
    "StatusCode"
  ]
}

Sample Code Snippet for: Lead Scoring Model

{
  "addField": {
    "predictedLeadScore": {
      "type": "object",
      "labelHint": "[[$fields.AILeadScore.metadata.labelHint]]",
      "value" : "[[ $fields.AILeadScore.value ]]",
      "properties": {
        "AILeadScore": {
          "value": "{{ $fields.AILeadScore.value }}",
          "metadata": "[[ $fields.AILeadScore.metadata ]]"
        },
        "mode": {
          "value": "drawer"
        },
        "resource": {
          "value": "leads"
        },
        "primaryKey": {
          "attribute": "LeadId",
          "value": "{{ $fields.LeadId.value }}",
          "metadata": "[[ $fields.LeadId.metadata ]]"
        },
        "selfLinkKey": {
          "attribute": "LeadNumber",
          "value": "{{ $fields.LeadNumber.value }}",
          "metadata": "[[ $fields.LeadNumber.metadata ]]"
        },
        "context": {
          "value": "[[ {'feature': 'salesmlprediction', 'usecasecode' : 
              'CX_LEAD_SCORING', 'title': $fields.Name.value()} ]]"
        },
        "displayField": {
          "attribute": "AILeadScore",
          "value": "{{ $fields.AILeadScore.value }}",
          "metadata": "[[ $fields.AILeadScore.metadata ]]"
        }
      },
      "referencedFields": [
        "AILeadScore",
        "LeadId",
        "LeadNumber",
        "Name"
      ]
    }
  }
}
When defining a virtual field, the following properties must be configured:
Name Description
labelHint Represents the label (field name) that will be displayed in the UI.
value Holds the value of the field for that record ( Field Value ) that you want to expose.
properties
  • resource Contains information about the object the field belongs to, for example: If the field belongs to an Opportunity object, resource will reference that.
  • displayField Specifies the field being exposed in the UI, for example displayField: PredWinProb.
  • primaryKey The primary identifier for the object. This value is fixed for each object type. For example primaryKey": "OpportunityId" for an Opportunity object.
  • selfLinkKey A fixed value used to reference the object’s self-link. For example: selfLinkKey : self .
  • mode This value is fixed and indicates that the field should open a drawer when clicked. For example mode : drawer.
  • context Used for sending custom context information to the hyperlink listener and accepts a JSON object where you can pass multiple key-value pairs.
  • To ensure the drawer displays explanations for SalesML predictions, the context must contain three key-value pairs: as follows:
    • feature – Must always be 'salesmlprediction'. If this is missing, the explanation layout will not load.
    • usecasecode – Represents the active model’s use case code for fetching explanations via REST API.
      • This value can be conditional also.
      • Example If StatusCode is "OPEN", usecasecode is set to "OPEN_ALANTHO", otherwise, it defaults to "CX_OPPORTUNITY_WIN_PROBABILITY"
      "context" : { "value" : "[[ {'feature': 'salesmlprediction', 'usecasecode' : $fields.StatusCode.value() == 'OPEN' ? 'OPEN_ALANTHO' : 'CX_OPPORTUNITY_WIN_PROBABILITY', 'title': $fields.Name.value()}
    • title – The heading of the drawer that opens. Typically set to the record name.
  • referencedFields Must include all distinct fields referenced in the configuration.

Exposing Your Virtual Field as a Link Field

Once you've created your virtual field, you need to edit the header layout to display this field in the UI as follows:
  1. Navigate to the object's Rule Sets and select the Header Layout of the relevant object such as Lead.

    Screenshot of the Header Layout rule sets

  2. Duplicate the rule and clone the layout as follows:

    Screenshot highlighting from where to duplicate a rule and create a copy of the layout

  3. Add the virtual field and drag into any available slot on the layout header.

    Screenshot highlighting from where to drag your virtual field to the layout

  4. Map the virtual field to the Global Hyperlink Template

    • Ensure that the virtual field is mapped to the global hyperlink template, which is predefined and ready-to-use.

      The global hyperlink template ensures that clicking the virtual field opens a drawer with the explanations of the Machine Learning predictions.

    • Follow these steps to link to the hyperlink template:
      • Open the JSON tab of the layout configuration.
      • Scroll through the JSON and find "addTemplates" section as follows:

        Screenshot highlighting the JSON tab of the layout configuration

      • Add the following code to the "addTemplates" section:
        Note: Replace the virtual field ID in the code snippet with your Virtual Field ID.
      • "addTemplateMap": {
            "/HeaderLayout": {
              "predictedLeadScore": "/hyperlinkTemplate"
            }
          }
  5. Add the attribute referenced as "value" in the Virtual Field to the cloned template.

    Screenshot highlighting the "value" in the Virtual Field to the cloned template

  6. Test and publish your changes. When complete, click the virtual field link to open a drawer that displays the explanations of the Machine Learning predictions.

    Here's an example of what this will look like when the link is created and the panel displays.

    Screenshot exposing a Predicted Win Probability linked field, which when clicked, open a drawer to display prediction factors