Friday, April 28, 2017

Add Chatter into Einstein Analytics

Another request that's appeared a few times is to have chatter more accessible within Einstein Analytics. With the action framework you can include global actions based upon the Id reference of a single record. In this example we will add the Opportunity chatter feed via a custom apex page making it accessible on the Name field of an Einstein Analytics visualization. 

Here's a screenshot of what it will look like within Einstein Analytics when we are complete.




Before we begin, this assumes that you have an Opportunity dataset that includes the "Name" and "Id" fields available from the Opportunity object. And that these are based on real opportunities that exist within your instance.


Let's get started.



  1.   Activate the Developer Console

  1.   Create a new Visualforce Page -> File -> New -> Visualforce Page


  1.   Name the file "ChatterGlobalAction", or replace your name in the subsequent actions.
  2.   Save the following text for the Visualforce page
<apex:page standardController="Opportunity">
    <apex:outputPanel layout="block" style="overflow:auto;height:500px" >
      <chatter:feed entityId="{!Id}"/>
    </apex:outputPanel>
</apex:page>
  1. Go to Setup - Build -> Customize -> Opportunities -> Buttons, Links, and Actions  (Note - for other global actions you might want to considering - Build -> Create -> Global Actions -> Global Actions)
  2. Create a "New Action" 
    Action Type: Custom Visualforce
    Visualforce Page: ChatterGlobalAction
    Height: 500px
    Standard Label Type: <none>
    Label: View and Post to Chatter
    Name: View_and_Post_to_Chatter
    Description: <blank>
    Icon: <left as is>
  1. View an opportunity
  2. Activate the Edit Layout

  1. Click on Quick Actions

  1. Drag the "View and Post to Chatter" button to the quick action Publisher section


  1. Save the update
  2. NOTE (I need to update this with screenshots of editing the action framework UI for this and the next step) Create the following xmd file on your local computer and save it with a name like opp.xmd.json. This is the step that will activate the action framework within Einstein Analytics. If you look at the code below, when you invoke "visit the record", the linkTemplate specifies how to build the link to visit the record. You can activate this selection with either the "Name" or "Id" fields based on this configuration. The recordIdField indicates what to pass to the global action.
{
    "dataset": {},
    "dates": [],
    "derivedDimensions": [
    ],
    "derivedMeasures": [],
    "dimensions": [
        {
            "customActions": [],
            "field": "Name",
            "linkTemplate": "/{{row.Id}}",
            "linkTooltip": "Opportunity",
            "members": [],
            "recordDisplayFields": [],
            "recordIdField": "Id",
            "salesforceActions": []
        },
        {
            "customActions": [],
            "field": "Id",
            "linkTemplate": "/{{row.Id}}",
            "linkTooltip": "Opportunity",
            "members": [],
            "recordDisplayFields": [],
            "recordIdField": "Id",
            "salesforceActions": []
        }        
    ],
    "measures": [],
    "organizations": [],
    "showDetailsDefaultFields": []
}


  1. Upload the XMD to your opportunity dataset 


  1. Group Opportunities by Name
  2. Then you can pull up the action menu to select the new Chatter Global Action




No comments:

Post a Comment