cancel
Showing results for 
Search instead for 
Did you mean: 

Access url parameter from sisense script

riaj03
7 - Data Storage
7 - Data Storage

Hi, we are embedding sisense report from our react app by iframe. 

```

<iframe src={url} style={{ width: '100%', height: '100vh' }}></iframe>
```
 
Its working perfectly, but we need to send extra parameter that can be accessed by sisense script
 
```
<iframe src={`${url}?custom_auth_token=xyz`} style={{ width: '100%', height: '100vh' }}></iframe>
```
 
Then we need to access this token here
 

/*
Welcome to your Dashboard's Script.

To learn how you can access the Widget and Dashboard objects, see the online documentation at https://sisense.dev/guides/js/extensions
*/

const authToken = {way to access token}

3 REPLIES 3

IsaacBlanco
8 - Cloud Apps
8 - Cloud Apps

Hey @riaj03 , I'm not quite sure if is possible inside a dashboard script, I know that inside an add on is possible, but you can try this.

Put an message listener in both your React code and in your dashboard script. In this way you can communicate with postMessages between them, once you have your information you can send it out through the postMessage to the iframe.

moti-sisense
Sisense Team Member
Sisense Team Member

The simplest JavaScript method to extract query parameters from the URL is:

/* If the URL has the query parameter ?myparam=123 */
const myParam = new URL(location.href).searchParams.get('myparam'); // myParam = '123'

You can use this in the dashboard script, however keep in mind that if this is needed across multiple dashboards or all dashboards, it would be better to implement as an Add-on to make maintenance easier (one shared add-on is easier to modify than multiple copies of the same dashboard script)


Moti Granovsky | Product Director @ Sisense

DRay
Community Team Leader
Community Team Leader

Hello @riaj03,

Did any of the solutions offered by work for you? If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)