Search results

Steps to embed the data source in your application

Follow these steps to embed data source in your application.

How to use BoldBI wrapper inside your html page

  1. In your .html page, you need to add the following Embed SDK URL in the head tag of your page.

    <head>
        <script type="text/javascript" src="https://cdn.boldbi.com/embedded-sdk/v6.1.8/boldbi-embed.js"></script>
    </head>
  2. In the body tag, you need to create the div element with your own id name. This element will be used for data source embedding.

    <body>
        <div id="datasource_container"></div>
    </body>
  3. In the body tag, you need to add the function to create BoldBI instance with following properties and call that function in the body using the onload attribute as follows. Also, call the loadDatasource() function.

    You can embed the data source using either the data source ID or data source name as shown in the following code samples:

    Embed using data source ID

    <body onload="embedSample();">
        <div id="datasource_container"></div>
        <script>
            function embedSample() {
                var boldbiEmbedInstance = BoldBI.create({
                    serverUrl: "http://localhost:51777/bi/site/site1",
                    datasourceId: "755e99c7-f858-4058-958b-67577b283309",                
                    embedContainerId: "datasource_container",// This should be the container id where you want to embed the datasource
                    embedType: BoldBI.EmbedType.Component,
                    environment: BoldBI.Environment.Enterprise,
                    mode: BoldBI.Mode.DataSource,
                    height: "800px",
                    width: "1200px",
                    authorizationServer: {
                        url: "http://example.com/embeddetail/get"
                    },
                    expirationTime: "100000",
                });
                boldbiEmbedInstance.loadDatasource();
            }
        </script>
    </body>

    Embed using data source Name

    <body onload="embedSample();">
        <div id="datasource_container"></div>
        <script>
            function embedSample() {
                var boldbiEmbedInstance = BoldBI.create({
                    serverUrl: "http://localhost:51777/bi/site/site1",
                    datasourceName: "Datasource Name",     
                    embedContainerId: "datasource_container",// This should be the container id where you want to embed the datasource
                    embedType: BoldBI.EmbedType.Component,
                    environment: BoldBI.Environment.Enterprise,
                    mode: BoldBI.Mode.DataSource,
                    height: "800px",
                    width: "1200px",
                    authorizationServer: {
                        url: "http://example.com/embeddetail/get"
                    },
                    expirationTime: "100000",
                });
                boldbiEmbedInstance.loadDatasource();
            }
        </script>
    </body>

    Creating datasource in datasource embedding

    If you need to create a new data source in embedding, then set the mode as connection as shown in the following samples and call the loadDatasource() function. The embedded user needs to have data source create permission to create data source in data source embedding.

    <body onload="embedSample();">
        <div id="datasource_container"></div>
        <script>
            function embedSample() {
                var boldbiEmbedInstance = BoldBI.create({
                    serverUrl: "http://localhost:51777/bi/site/site1",
                    embedContainerId: "datasource_container",// This should be the container id where you want to embed the datasource
                    embedType: BoldBI.EmbedType.Component,
                    environment: BoldBI.Environment.Enterprise,
                    mode: BoldBI.Mode.Connection,
                    height: "800px",
                    width: "1200px",
                    authorizationServer: {
                        url: "http://example.com/embeddetail/get"
                    },
                    expirationTime: "100000",
                });
                boldbiEmbedInstance.loadDatasource();
            }
        </script>
    </body>
  4. Refer the following table for the values of the previous properties based on your application.

    serverUrl Use your Bold BI server url (http://localhost:[portno]/bi/site/site1)
    datasourceId Use item id of the datasource, which needs to be edited in embedded datasource in your application.
    datasourceName Use datasource name of the datasource, which needs to be edited in embedded datasource in your application.
    embedContainerId Id of the created div element in your body.
    embedType BoldBI.EmbedType.Component
    environment BoldBI.Environment.Cloud or BoldBI.Environment.Enterprise
    height Height of the datasource designer in your page
    width Width of the datasource designer in your page
    authorizationServer Use your authorization URL
    expirationTime Token expiration time
  5. Copy the previous embedSample() function and paste in your page. You need to update your values to the properties.

NOTE: embedContainerId should be same as your div element id value.

NOTE: For Bold BI v5.2.48 or lower version, you must have add the following dependent scripts and also refer the below Embed SDK URL of respective Bold BI version.

https://cdn.boldbi.com/embedded-sdk/v5.2.48/embed-js.js

Bold BI Version Dependent Scripts
v5.2.48 or Lower
<head>  
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsrender/1.0.0-beta/jsrender.min.js"></script>
    <script type="text/javascript" src="https://cdn.boldbi.com/embedded-sdk/v5.2.48/embed-js.js"></script>
</head>

v5.3.53
<head> 
    <script type="text/javascript" src="https://cdn.boldbi.com/embedded-sdk/v5.3.53/boldbi-embed.js"></script>
</head>

v6.1.8
<head> 
   <script type="text/javascript" src="https://cdn.boldbi.com/embedded-sdk/v6.1.8/boldbi-embed.js"></script>
</head>

How to implement the authorize server with user mail or user name

  1. You need to implement authorization end point in your application. This will act as the bridge between your application and Bold BI server and also you need to update the secure details like email and group based access. Learn more about authorize server here.

  2. To create authorization-server action method, copy the following snippet in your controller. You can use currently logged in user email at user@domain.com or user name at username, but this user must have access to the dashboard.

    [HttpPost]
    [Route("embeddetail/get")]
    public string GetEmbedDetails(string embedQuerString, string dashboardServerApiUrl)
    {
        // User your user-email as embed_user_email
        embedQuerString += "&embed_user_email=user@domain.com";
    
        // Use your user-email as embed_user_email
        //embedQuerString += "&embed_user_email=username";
    
        //To set embed_server_timestamp to overcome the EmbedCodeValidation failing while different timezone using at client application.
        double timeStamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
        embedQuery += "&embed_server_timestamp=" + timeStamp;
    
        var embedSignature = "&embed_signature=" + GetSignatureUrl(embedQuerString);
    
        var embedDetailsUrl = "/embed/authorize?" + embedQuerString + embedSignature;
    
        using (var client = new HttpClient())
        {
            client.BaseAddress = new Uri(dashboardServerApiUrl);
            client.DefaultRequestHeaders.Accept.Clear();
    
            var result = client.GetAsync(dashboardServerApiUrl + embedDetailsUrl).Result;
            string resultContent = result.Content.ReadAsStringAsync().Result;
            return resultContent;
        }
    }
  3. Add the GetSignatureUrl method, and this method will be called from the previous GetEmbedDetails action. Follow the next section to get EmbedSecret key from the Bold BI application.

    public string GetSignatureUrl(string queryString)
    {
        // Get the embedSecret key from Bold BI.
        var embedSecret = "8apLLNabQisvriG2W1nOI7XWkl2CsYY";
        var encoding = new System.Text.UTF8Encoding();
        var keyBytes = encoding.GetBytes(embedSecret);
        var messageBytes = encoding.GetBytes(queryString);
        using (var hmacsha1 = new HMACSHA256(keyBytes))
        {
            var hashMessage = hmacsha1.ComputeHash(messageBytes);
            return Convert.ToBase64String(hashMessage);
        }
    }

How to get Embed Secret key from Bold BI application

You can get your Embed Secret key from administrator setting section. Refer to this link for more details.

How to get common Embed Secret key from UMS

If you are using multi-tenant Bold BI server sites and want to embed the designer in your application, then we recommend using the common embed secret instead of the separate embed secret for each site. Refer to this link to get the common embed secret.

NOTE:
This embed setting will be enabled only if you have an Embedded BI plan.

Refer to this link to resolve the jQuery conflict problem in embedded.