BloX: replicating action “send me the report now”
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:
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).