How can we help?


Salesforce integration: Automatically update key results using Apex

Follow these six steps to setup and schedule automatic key result updates from Salesforce using Apex: 

Step 1: Create reports-result mapping through Salesforce custom metadata

Create customer metadata in Salesforce with customer field Report Id, Key Result Id, Column Number and Report Map Key.

Report Id: Your Salesforce report id (note: this is not the DeveloperName or unique identifier name that you define in Report's properties). Retrieve this report id using Workbench or Salesforce SOQL.

Column Number: Select which column from your aggregated results you would like to use to update your key result.  Column numbers start at 0.

Key Result Id: The unique data stream id in WorkBoard that you will push this data to.

Report Map Key: The implementation relies on the Salesforce Fact MAP -- use it to decide which cell you want to map from your Salesforce Report to Workboard’s result. The default value is T!T , which is the convention used for the grand summary in a report.

For summary at different levels, you can use 0!T, where '0' indicates summary at the top level.

Use text as the data type for custom metadata fields.

Step 2: Create Apex class

Create an Apex class with the code provided in WoboStreamReportExecutor 

Update your access token in the class. To get your access token, please follow these steps:

  1. Login to your Workboard account
  2. Click on your profile/setting icon on top-right corner and select “Integration & Import”
  3. Click on Customer Integration tab
  4. Click on the “App” tab.  Under the “Instant Token” section, click on “click here” to generate an instant token. Only generate the instant token if you don’t have one. If you are already using an instant token in your deployment, then generating a new token will break your existing deployment.

Step 3: Authorize remote site in Salesforce

  1. In your Salesforce account, go to Setup->Security->Remote site settings
  2. Click on New Remote Site and enter as remote site URL


Step 4: Test

Test the Apex class in "Open Execute In Anonymous Window"

Step 5: Deploy Test coverage

To get minimum test coverage, you can use the sample test coverage class.

Step 6: Schedule

Instructions on scheduling an Apex class for regular updates.

Was this article helpful?
0 out of 0 found this helpful


Article is closed for comments.

Need more help? Submit a request.