cancel
Showing results for 
Search instead for 
Did you mean: 
OleksiiDemianyk
Sisense Team Member
Sisense Team Member

BloX: replicating action “send me the report now”

This article explains how to develop an action to send a dashboard as a report to the end user. This action replicates the action “Send me the report now”. This action is available only to the dashboard’s owner, but we will develop a BloX action, which will be available for other users.

To solve this challenge you will need to do the following:

  • Create a widget of the type ‘BloX’ on the dashboard you want to have the ability to send reports to the end-users;
  • Create a custom action with the following code:

 

 

 

const { widget } = payload; //Get widget’s object from the payload
const internalHttp = prism.$injector.get('base.factories.internalHttp'); //Get internal factory to run API requests


internalHttp({
   url: '/api/v1/reporting',
   method: 'POST',
   contentType: 'application/json',
   data: JSON.stringify({
       assetId: widget.dashboard.oid,
       assetType: "dashboard",
       recipients: [
           {
               type: 'user',
               recipient: prism.user._id
           }
       ],
       preferences: {
           inline: true
       }
   })
}).then(res => console.log(res.data));

 

 

This action will have the following snippet:

 

{
  "type": "sendMeReport",
  "title": "Send me report"
}

 

Use this snippet in the widget you have created:

 

{
   "style": "",
   "script": "",
   "title": "",
   "showCarousel": true,
   "body": [],
   "actions": [
       {
           "type": "sendMeReport",
           "title": "Send me report"
       }
   ]
}

 

Now, you have a button on the widget. After clicking this button, Sisense will send a report for the currently authenticated user.

Please, note that there will be no indication of the running action. When the action is completed there will be a message in the browser’s console. Feel free to customize the logic of this action to show the end-user that the report is generating.

Custom action is a powerful tool, which allows you to create custom interactions. Use this approach to create a new action easily. You can customize the proposed action by adding an indication of the running action or by using custom parameters to change format or size of the generated report (check the description of the endpoint /api/v1/reporting for additional information).

Check out related content:
Creating customer actions
Reporting Send Reports

Rate this article:
Version history
Last update:
‎01-13-2025 09:18 AM
Updated by: