Sisense Community logo
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
      • Official Sisense Discord
    • Use Case Gallery
    Discussions
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • TagsChevronRightIcon
    Why Migrate
      • BloxChevronRightIcon

      Quickly Add Unique Identifier to Blox Action Buttons Without Modifying Blox Template

                                                                                       

      Quickly Add Unique Identifier to Blox Action Buttons Without Modifying Blox Template A customer recently had the unusual request for a method to select and distinguish, via a CSS selector used within a custom Javascript action, for specific Blox buttons  in a existing Blox widget that contained multiple identical buttons, identical in inner text and all other parameters, without adding any new lines to the Blox template to add unique identifiers.  The customer had concerns that using the index order of the buttons, where the button was selected based on order, may be likely to break in the future, due to a potentially minor change. The method used for making the least possible change to the Blox template, requiring no new lines or new parameters, while also creating a unique resilient CSS selector method for each button unlikely to be broken by future changes to the template while using an existing parameter, was to use the unexpected route of using the existing " font-size " inline styling as a unique CSS and JS selector, using very small decimal precision that was irrelevant to the rendering of the button itself, but allowed for a unique selecting parameter, without adding a single new line of Blox templating. Blox places CSS styling to actions inline, and this allows for this unusual form of element tagging, where CSS can select based on inline styling text.  This is implemented by adding unnecessary and unique precision to the font-size parameter of a Blox template line such as this:   "actions": [ { "style": { "font-size": "13px" },   with a very similar line:   "actions": [ { "style": { "font-size": "13.01px" },    This results in Blox generating the following HTML with inline styling:   <ul class="action-set"> <li class="action"> <button class="btn btn__text" style="font-size: 13.01px;"> Button Text </button> </li> </ul>   This then allows that unique button to be selected via the CSS selector (used in code):   button[style*="font-size: 13.01px"]   This was then repeated for all other buttons (13.02, 13.03...) in both the template and code. The standard Javascript querySelector or jQuery (included in all Sisense web pages) can use this as a CSS selector to return the specific button. This method is valid because CSS treats inline style as any other HTML attribute , so the attribute selector in modern CSS can be used, by treating the "style" parameter as any other HTML attribute of an element. As would be expected, this hundredth pixel does not affect the actual rendering of the button, and while not at all necessary can be identically by using the thousandth decimal place or smaller. While Blox does place action font-size styling inline, it is worth emphasizing that this kind of pseudo-recursive CSS selectors based on inline styling, is only possible when styling is inline and not applied via stylesheets. This request is rather unique, and this method was only required due to the very specific nature of the request and the customer's specific concerns, but the method was unusual and unexpected and worth noting for other Sisense users who may have a similar restrictive use case of selecting otherwise unique Blox action buttons and making very minimal changes to the Blox templating of a Blox type widget.  Share your experience in the comments! 

      Jeremy Friedel
      Jeremy FriedelPosted 2 years ago • Last reply 2 years ago
      2
               
    • Blog banner
      • BloxChevronRightIcon

      Migrating Blox Custom Actions

                                                                                       

      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"}   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! 

      Jeremy Friedel
      Jeremy FriedelPosted 2 years ago
      0