From Andy Haas: Use Analytics Management Actions to Show Report Subscribers and Assignments
Author: Andy Haas
Have a user(s) subscribed to five reports and can’t subscribe to any other reports? Or do you have users that don’t know which reports they are subscribed to and want to be removed? This component allows you to achieve just that. Utilizing the Analytics Notifications API returns APEX-defined records, and utilizing the Datatable by Eric, you can show the records and see who is assigned to specific reports. Added to the last action, you can remove users or remove a subscription from the report.
Take a look at how you can set up this action and utilize it below.
Video Walkthrough
Overview
Ever had a user state that they can’t subscribe to a report, or you want to see who is subscribed to which reports in a quick view. The Analytics Notification API is the key but is not accessible from the flow builder. That is where this component comes into play. This APEX invocable action will allow you to call the Analytics Notifications API to view report subscriptions, dashboard subscriptions, or wave notifications; not only that, you can get all notifications for a user or a record.
The best use of this component is with the Data Table Eric created, where you can use APEX Defined classes. Below are examples of what I came up with. All multi-dimensional objects have their own APEX class so that you can get deep into the details of the response. Lastly, this component will allow you to delete specific users from a subscription.
Basic Flow Setup
Advanced Flow Setup
Remote Site Settings
You will need to add a remote site setting that loops back to your salesforce domain for this to work correctly.
Component Details:
Get Subscription Data
Uses the Analytics Notification List API Documentation, which can be found here:
Attributes:
Inputs
source | Required for GET calls. Specifies what type of analytics notification to return. Valid values are:lightningDashboardSubscribe — dashboard subscriptionslightningReportSubscribe — report subscriptionswaveNotification — Analytics notifications |
ownerId | Optional for GET calls. Allows users with Manage Analytics Notifications permission to get notifications for another user with the specified ownerId. If you don’t enter a value the running users id is used. |
recordId | Optional. Return notifications for a single record. Valid values are:reportId— Unique report IDlensId— Unique Analytics lens ID |
Outputs:
definition_string | A stringified version of the Get Response Body |
definition | An APEX defined class of the Definition Response |
definitionDetails | A subclass that pulls out some key details from sub classes. This class also pulls in the Report Name which is not included in this API |
definitionDetails_string | A stringified version of definitionDetails to be used within the data table |
Parse Recipient Data
This is a helper class that will parse the selected row and gets the recipients that are subscribed to the selected record.
Attributes:
Inputs
definition_string | A string array of a single definition string record. This is normal output of a record selection from a data table |
Outputs:
recipients_string | Gets a collection of recipients that follows the Recipient class that can be used within the data table |
recipients | An APEX defined class of the recipients that were parsed |
notificationId | The specific ID of the notification that was selected |
definition | An APEX defined class of the Definition Response |
Delete Selected Recipients
Uses the Analytics Notification API with the Method PUT if you are adjusting users or delete if you are removing all users. That documentation can be found here:
Attributes:
Inputs
definition | A string array of a single definition string record. This is the normal output of a record selection from a data table |
deletedRecipients | The recipients we want to remove from the notification. This is in a string array. This is the normal output of a record selection from a data table |
notificationId | The ID of the notification we are updating or deleting |
recipients | All of the recipients that were parsed from Parse Recipient Data action |
Outputs: None
Get User Subscription Limit
Attributes:
Inputs
source | Required for GET calls. Specifies what type of analytics notification to return. Valid values are:lightningDashboardSubscribe — dashboard subscriptionslightningReportSubscribe — report subscriptionswaveNotification — Analytics notifications |
ownerId | Optional for GET calls. Allows users with Manage Analytics Notifications permission to get notifications for another user with the specified ownerId. If you don’t enter a value the running users id is used. |
Outputs
max | How many analytics notifications of the type specified by source the user is allowed to create. |
remaining | How many more analytics notifications of the type specified by source the user can create before hitting the limit. |
Install
This extension requires FlowActionsBasePack version 3.8 or higher
1.0 12/2 Production Sandbox Initial Version
Source
Limitations:
You can only see subscriptions from a particular user. If you subscribe another user to a report and you pass in their Id into ownerId you will not see that subscription, you would need to pass in the person who subscribed the user to the report.