Following our last post on using the Wave API to create targeted campaigns, we will now use the API to backup Wave assets as document sObjects.

The Wave API allows us to access the metadata around Wave assets, whether they are JSON files behind dashboards and lenses, or metadata around Wave Apps. To do a backup of dashboards and lenses, the asset endpoints can be used. Specifically they are /wave/dashboards and /wave/lenses.

Step 1: Get the Dashboard IDs

To start, the IDs are collected for all the dashboards available to the user using Apex:

If a user has access to many dashboards, sometimes you need to page through them to collect all the user’s dashboards. You can do this by using the query arguments “page” and “pageSize” in the API URL (more on this here). Once a response is received with a list of all the dashboards available to the current user, we can parse the response to find the ID of each dashboard:

Step 2: Get the State of Each Dashboard

Once we have our list of dashboardIds, we can iterate over them to get the “state” node from each underlying JSON file. This node is the primary one defining all the queries and widgets on your dashboard. The other nodes are based on system defined properties which we cannot use later when restoring our dashboards and hence they will be ignored here. To do this, the future annotation for methods will be used which has a much greater limit of Http callouts than a typical synchronous method.

Now that you have the dashboard IDs, you can call the method:

Implementation Notes

  • This process can be extended to download other assets such as lenses and dataset XMD JSON files. After the actual download of assets is completed, it can also save these JSON files in version control systems such as Git.
  • Since this is an async method, it will be queued to run when resources are available. The Apex process can be monitored by going into Setup->Monitor->Apex Jobs.
  • After the process completes, the user’s dashboards are stored in a folder with the name “<dashboard Name>_<system date>.json”.
  • This process could be run on a scheduled basis using the Apex Scheduler, or by a user invoking the process. Note that if a user invokes the process, it’s still an asynchronous method, and will run when resources are available.

About the Author

Tomasz Bacewicz is a Senior Consultant dedicated to providing solutions in accelerating & optimizing implementation of Wave. Tomasz is a member of the Analytics Cloud’s ASG team.

About the Advanced Solutions Group

A specialized analytics team in the Analytics Cloud product organization that provides world-class technical leadership and guidance focused on empowering the Wave ecosystem. ASG helps drive rapid value by leveraging deep technical knowledge of the Wave platform and apps.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS