cancel
Showing results for 
Search instead for 
Did you mean: 
JeremyFriedel
Sisense Team Member
Sisense Team Member
Migrating Blox Custom Actions
 
When relocating Sisense resources from one server to another, the Sisense Rest API is a possible method for transferring Sisense components and objects like dashboards, users, groups, and data sources. Similarly, Blox Custom Actions can be migrated through Sisense Rest API endpoints.

Dashboards that rely on custom Blox actions not yet migrated or manually recreated will lack specific Blox action functionality if the Blox custom actions are absent from the hosting Sisense server.

Blox custom actions are objects containing Javascript code capable of introducing custom functionalities not inherent in the default set of Blox actions. Detailed documentation is available here as well as here. Custom action code can be quite extensive and powerful, often matching those achievable by dashboard or widget scripts, but only upon a user triggering a Blox action, such as clicking a Blox button.

This article provides instructions for both retrieving existing Custom Blox Actions via API endpoints and creating new Custom Blox Actions via API endpoints. Although the primary focus is on migration, this article applies to various contexts, including scenarios where only a copy of all current Blox actions is needed from a server or the creation of an entirely new Blox action from scratch using the create Blox action API.

To retrieve the list of Blox custom actions from a Sisense server, use the following endpoint:

GET /api/v1/blox/getSnippets?snippetType=actions

To fetch the full body of an individual Blox custom action, employ the following endpoint:

POST /api/v1/getActionByType/BloX

Payload structure of this endpoint:

{"type": "nameOfBloxAction"}
 
Screen Shot 2023-12-11 at 5.21.27 PM.png
To create or migrate a Blox action, utilize the following endpoint:

POST /api/v1/blox/saveCustomAction

The payload for the new Blox action can be directly copied from the GET getActionByType request. The template structure of the payload for the saveCustomAction is provided below:

 

 

{
    "type": "bloxActionTitleHere",
    "body": "Full Code Here",
    "snippet": {
        "type": "bloxActionTitleHere",
        "title": "title"
    },
    "step": "2"
}

 


For Windows and older Sisense versions, the API URL endpoint to fetch actions differs slightly:

GET /v1/getCustomActions/actions

Similarly, the older Windows endpoint URL for saving or creating Blox actions is:

POST /v1/saveCustomAction/BloX

The API endpoint for editing an existing Blox action mirrors the endpoint used for creating new endpoints, simply use the name of the existing action with the modified body text.

Any code changes required for Blox actions compatibility due to an OS or Sisense version change must still be implemented; the API endpoints migrate Blox actions as-is and do not include any modification of the body text.

These API endpoints facilitate all Blox custom action functionality, whether editing existing Blox custom actions or saving all current Blox custom actions to a file.

Share your experience in the comments! 

Rate this article:
Version history
Last update:
‎12-12-2023 10:04 AM
Updated by: