Javascript error when calling getSheetVisuals

I am using the amazon-quicksight-embedding-sdk to embed a dashboard and I am trying to programmatically add a custom action to a visual on the second sheet of a dashboard.

When I try calling getSheetVisuals(sheet2Id) on the CONTENT_LOADED event (in order to add the action to the visual) I get an empty array, even though there’s a visual on the sheet.

case 'CONTENT_LOADED': {
    const sheets = await embeddedDashboard.getSheets()
    // always empty array:
    const visuals = await embeddedDashboard.getSheetVisuals(sheets[1].SheetId))

I presume this is because the dashboard is currently showing the first sheet and the second sheet hasn’t loaded (?). But when I try calling getSheetVisuals(sheet2Id) on the SELECTED_SHEET_CHANGED event (checking that it’s referring to the second sheet), I get a javascript error:

   case 'SELECTED_SHEET_CHANGED': {
       const visuals = await embeddedDashboard.getSheetVisuals(msg.message.selectedSheet.SheetId)

What is the correct way to add a custom action to a visual on the second sheet of an embedded dashboard?

Hello @alvaro , welcome to the Quicksight community!

When you say the second sheet hasn’t loaded what do you mean by that?

@duncan It’s just my guess as to why when I request the visuals for the second sheet I get an empty array (the second sheet has 2 visuals). When the dashboard loads, the first sheet is shown. My guess was that the second sheet (not yet visible) was not in a state to receive custom actions until the user switched to it and was “loaded”.

Maybe that’s not the reason and I am misunderstanding… If so, why am I getting an empty array when querying for visuals for the second sheet?

And the broader question: When is the right time to attach custom actions at runtime? Do I have to wait until the sheet is selected? What about when I programmatically navigate to a different dashboard? Is there an event I can listen for that signals that the dashboard is ready to receive custom actions? CONTENT_LOADED only seems to be triggered once at the very beginning, not after changing sheets or navigating to a new dashboard.

Hey @alvaro ,sorry to get back to you so late !

I want to make sure you’ve published that second sheet with its visuals from the analysis to the dashboard? If so, can you confirm if you are using createEmbeddingContext() from amazon-quicksight-embedding-sdk? Knowing the process of your embedding will help me troubleshoot at what step you’re at when you get this error.

My understanding is you use the embedDashboard function with the options you defined (that switch statement), at which point those should actually have information on the dashboard and all sheets attached. If you’re embedding a dashboard with multiple sheets, you dont have to do anything special to get the rest of the sheets.

So if you only see 1 sheet when you embed, my guess is that it’s not published, but let me know!

Hi @alvaro ,

Thank you for letting us know regarding this issue.
I would recommend filing a case with AWS Support where we can dive into the details so that we can help you further. Here are the steps to open a support case. If your company has someone who manages your AWS account, you might not have direct access to AWS Support and will need to raise an internal ticket to your IT team or whomever manages your AWS account. They should be able to open an AWS Support case on your behalf.

I have cut an internal ticket (https://t.corp.amazon.com/V1009408962) to embedding team for them to take a look into this. You can quote this ticket number while opening your support case to get status on it.

To answer your other question, when navigating to different dashboard, a NAVIGATE_TO_DASHBOARD event is emitted.

Regards,
Arun Santhosh