Embedding Quicksight Visual with parameters

0

We have a QuickSight dashboard in which we have a filter on a particular visual. We are trying to embed the visual in our application. I am able to generate the embed URL for the visual using the documentation. However, the parameters being passed are being reset to default which can be inferred from the following event which I see triggered once the content is loaded.

{
  "eventTarget": {
    "experienceType": "VISUAL",
    "discriminator": 0,
    "contextId": "123",
    "dashboardId": "xyz",
    "sheetId": "abc",
    "visualId": "pqr"
  },
  "eventName": "PARAMETERS_CHANGED",
  "message": {
    "changedParameters": [
      {
        "Name": "Lane",
        "Values": [
          "All"
        ]
      }
    ]
  },
  "timestamp": 1681736836332,
  "eventId": "7965be29-c80e-4ab0-97cc-00a81ba5d664"
}

What we are trying to embed is the tabular visual from the following dashboard: Enter image description here

We have a QuickSight dashboard in which we have a filter on a particular visual. We are trying to embed the visual in our application. I am able to generate the embed URL for the visual using the documentation. However, the parameters being passed are being reset to default which can be inferred from the following event which I see triggered once the content is loaded.

{"eventTarget":{"experienceType":"VISUAL","discriminator":0,"contextId":"123","dashboardId":"xyz","sheetId":"abc","visualId":"pqr"},"eventName":"PARAMETERS_CHANGED","message":{"changedParameters":[{"Name":"Lane","Values":["All"]}]},"timestamp":1681736836332,"eventId":"7965be29-c80e-4ab0-97cc-00a81ba5d664"} What we are trying to embed is the tabular visual from the following dashboard:

Following are the parameters we are passing while loading the visual into application web page using amazon-quicksight-embedding-sdk

FrameOptions:
{
  "url": "EMBED_URL",
  "container": "CONTAINER_ID",
  "height": "100px",
  "width": "100%",
  "onChange": "",
  "resizeHeightOnSizeChangedEvent": false
}
`Content Options:
{
  "toolbarOptions": {
    "export": false,
    "undoRedo": false,
    "reset": false
  },
  "sheetOptions": {
    "initialSheetId": "SHEET_ID",
    "singleSheet": true,
    "emitSizeChangedEventOnSheetChange": false,
    "sheetId": "SHEET_ID"
  },
  "attributionOptions": {
    "overlayContent": false
  },
  "parameters": [
    {
      "Name": "Lane",
      "Values": [
        "MENASHA,WI - HANOVER,MD"
      ]
    }
  ]
}

The frame loads appropriately, however the parameter does not seem to be applied as am expecting to see a single row. The same filtering works, with same parameters, when I embed the dashboard instead of a visual. Just wanted to understand if there is something am missing. Tried scavenging the documentation but unfortunately couldn't deduce much. Any pointers / directions would be much appreciated

Following is the code where we embed the parameters using the amazon-quicksight-embedding-sdk

embedVisual = async(props, quickSightUrl) => {
        const embeddingContext = await createEmbeddingContext({
            onChange: (changeEvent, metadata) => {
                console.log('Context received a change', changeEvent, metadata);
            },
        });
        const dashboardProps = props.dashboardOptions;
        if(dashboardProps){
            const frameOptions = this.getFrameOptions(dashboardProps, quickSightUrl);
            const contentOptions = this.getContentOptions(dashboardProps);
            console.log([frameOptions, contentOptions]);
            let embeddedDashboardOrVisual = null;
            embeddedDashboardOrVisual = await embeddingContext.embedVisual(frameOptions, contentOptions);
            this.setState({embeddedDashboardOrVisual: embeddedDashboardOrVisual});
        }
    }

    getFrameOptions = (props, dashboardUrl) => {
        console.log(document.getElementById(props.dashboardId + this.props.id));
        const frameProps = props && props.frameOptions;
        let options = {
            url: dashboardUrl ? dashboardUrl : props.dashboardUrl,
            container: document.getElementById(props.dashboardId + this.props.id),
            height: frameProps && frameProps.height ? frameProps.height : "700px",
            width: frameProps && frameProps.width ? frameProps.width : "1000px",
            onChange: (changeEvent, metadata) => this.onDashboardChange(changeEvent, metadata)
        }
        return options;
    }

    getContentOptions = (props) => {
        let options = {
            toolbarOptions: this.getToolbarOptions(props.toolbarOptions),
            sheetOptions: this.getSheetOptions(props.sheetOptions),
            attributionOptions: this.getAttributionOptions(props.attributionOptions),
            onMessage: async (messageEvent, experienceMetadata) => this.onMessage(messageEvent, experienceMetadata)
        }
        if(props.parameters && props.parameters.length > 0){
            options.parameters = props.parameters;
        }
        return options;
    }

    getToolbarOptions = (props) => {
        let options = {
            export: props && props.export ? props.export : false,
            undoRedo: props && props.undoRedo ? props.undoRedo : false, // use this option to show or hide the undo and redo buttons
            reset: props && props.reset ? props.reset : false, // use this option to show or hide the  reset button
        }
        return this.appendOptions(props, options);
    }

    getSheetOptions = (props) => {
        let options = {
            initialSheetId: props && props.sheetId ? props.sheetId : null,
            singleSheet: props && props.singleSheet ? props.singleSheet : false, // use this option to enable or disable sheet tab controls
            emitSizeChangedEventOnSheetChange: false, // use this option in combination with resizeHeightOnSizeChangedEvent property, to allow iframe height to resize dynamically, based on sheet height, on changing sheets.
        }
        return this.appendOptions(props, options);
    }

    getAttributionOptions = (props) => {
        let options = {
            overlayContent: props && props.overlayContent ? props.overlayContent : false,
        }
        return this.appendOptions(props, options);
    }

Following are the props parameters being passed to the **embedVisual** method.
dashboardOptions = {{
                     dashboardId: hard_coded_dashboardId,
                     visualId: hard_coded_visualId,
                     sheetId: hard_coded_sheetId,
                     frameOptions: {
                         height: '100px',
                         width: '100%',
                         resizeHeightOnSizeChangedEvent: false
                     },
                     toolbarOptions: {
                         export: false,
                         undoRedo: false,
                         reset: false
                     },
                     sheetOptions: {
                         sheetId: hard_coded_sheetId,
                         singleSheet: true
                     },
                     parameters: [{
                         Name: 'Lane',
                         Values: [lane && lane.toUpperCase()]
                     }]
                 }}
NikhilK
asked a year ago893 views
2 Answers
0

Hi, @NikhilK.

I think your approach using options.parameters is correct.
Please check the following:

  1. Can you provide your entire embed code? I want to know if the option parameter setting method is correct.
  2. Does the visual respond correctly if I explicitly set the same parameters with setParameters?
profile picture
EXPERT
iwasa
answered a year ago
  • Hi @iwasa, thanks for responding, appreciate your time. I've updated the question above to include the client code which is responsible for the embedding. For the point 2, are you talking about setting the parameters while retrieving the URL from quicksight? If so then I've not tried it yet but I will try it and update the finding here. That would be a good try indeed, thanks

0

Hello,

As per your use case, could you please check the what’s the URL for the iframe, and make sure it has the expected parameter in the query string.

Ex:if you want to use the value from the embedded URL, make sure you have parameter Lane in QS and &Lane={value} in the URL. If the value is not part of the predefined list, QS will show the default value. Additionally, If the value has space or special char, please make sure you are encoding correctly.

AWS API will be helpful get an anonymous embedded URL, and then add parameters manually to the URL in the code rather than SDK.

Hope this helps.

thanks!

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions