Salesforce Wave 101 – Dataflow JSON for Idiots

This is the JSON 101 version of working with Dataflow JSON. I’m going to skip anything that isn’t the straight up basics.

So there you go… downloading the JSON file because you:

  • Need to bring in additional fields
  • Want to bring in new objects
  • Just curious about what is happening

I Read This How?

To begin with the downloaded JSON file is ugly. Like “barely human readable” ugly. You need to format it. Fortunately this site https://jsonformatter.curiousconcept.com/ does a nice job of both formatting and validating JSON.

What’s Happening Here?

There are basically 3 actions occuring within this JSON file:

  • sfdcDigest – This is where you pull data from an object
  • Augment – If you need to connect two object’s data together, you need a join. Account to Contact for example
  • sfdcRegister – The creation of the dataset and assignment of security

How about some examples? Sure….

Extract

"Extract_Opportunity":{
      "action":"sfdcDigest",
      "parameters":{
         "SFDCtoken":"SFDCtoken",
         "fields":[
            {
               "name":"Id"
            },
            {
               "name":"AccountId"
            },
            {
               "name":"OwnerId"
            },
            {
               "name":"Name"
            },
            {
               "name":"StageName"
            }
			],
         "object":"Opportunity"
       }
   }

I’m pulling fields from the Opportunity object here. Notice that I identify via the field name (NOT label) all the fields I want to pull. This is obviously a snippet of all the fields that I would really want from the Opportunity record but it does work.

Now if I just registered this I’d basically create an island of data. I can’t connect it with an account or the owner. In fact all I would see is the Account Record ID’s. That’s no good. We need to join it up.

Augment but we call it a Join

"Join_OpportunityAccount":{
      "action":"augment",
      "parameters":{
         "right_key":[
            "Id"
         ],
         "left":"Extract_Opportunity",
         "left_key":[
            "AccountId"
         ],
         "right_select":[
            "Name",
            "Territory_ID__c",
            "Industry",
            "BillingCountry",
            "BillingState",
            "AccountSource",
            "OwnerId",
            "Owner.Name",
            "Owner.Role.Name",
            "Owner.Role.DeveloperName",
            "Owner.Role.Roles",
            "Owner.Role.RolePath",
            "Owner.Role.ParentRoleId"
         ],
         "right":"Join_AccountOwner",
         "relationship":"Account"
      }
   },

In a SQL world we would call this a JOIN. I have two sides of the Join:

  • Left – it is being stated as the Extract_Opportunity that I defined above as “left”:”Extract_Opportunity” (hey that looks familiar)
  • Right – Its being stated towards the bottom as being the Account: “relationship”:”Account”.

(now truth time it is actually calling another Augment “Join_AccountOwner. But let’s not get carried away with this.

The main point of above is that you are asking Wave to look at every AccountID in the Opportunity sfdcDigest and link its matching Account data using the two keys specified above. The two keys have to match. Account ID = Account ID. And obviously I recommend that these keys be unique.

Register

Okay so we have some data downloaded and we created a join (or 4 depending on needs) and now its time to create some datasets.

  "Register_Opportunity":{
      "action":"sfdcRegister",
      "parameters":{
         "SFDCtoken":"SFDCtoken",
         "rowLevelSecurityFilter":"'Owner.Role.Roles' == \"$User.UserRoleId\" || 'OwnerId' == \"$User.Id\"",
         "name":"Opportunities",
         "alias":"opportunity11",
         "source":"Join_OpportunityOwner"
      }
   },

Now what in the world is going on here?

  • The name and alias are what your users are going to see as the dataset name in Wave.
  • The source will be the joins you built above
  • rowLevelSecurityFilter – oh baby that is outside the perview of this discussion but basically the above will force security that you will only see data at your level of the role hierarchy and below. So a Sales User will see a certain sub-set of data while the Sales Manager will probably see more.

What Am I Going to Do With This?

We are fortunate people as more then likely we will be downloading a JSON file from Wave and then adjusting it. But at least you now understand the functions happening here.

  • Need to add a new field? Change the sfdcDigest for that object
  • Need to bring in a new object? Then you need to do all three actions

Salesforce Wave – Dataset JSON Download

Part of the deal with Wave is that you need to edit and mess with routinely the JSON files that power all the functionality. If for example you want to bring in new fields or objects into Wave, you can either:
Attempt to edit the JSON file for a particular dataset (hmmm)
Edit the jSON file for the who Dataflow.

Unless you have some massive datasets, its probably the easiest just to edit the dataflow’s JSON file.

Pretty easy to get there. Its within the gear icon labelled Data Monitor
Wave-WherearetheJSONFiles2
Switch over to Dataflow View
Wave-WherearetheJSONFiles1
Scroll down to the Dataflow you want to monkey with and click “Download”
Wave-WherearetheJSONFiles3
Obviously once you download and edit it, you need to upload the updated file for it to take effect. Fortunately the link to upload is there as well.

IF YOU WANT IT TO TAKE EFFECT IMMEDIATELY – then you need to rerun your dataflow. Otherwise the new settings will take effect on the NEXT run.

Be aware that if there is an existing dataset for an object that your edits here will NOT affect security. For that you need to edit the dataset itself and update there. (Thats true as of March 2016)