HomeBlogLightning Viz mapping fix
Salesforce · Communities

Fix to add mapping to Lightning Viz component in Lightning communities

Published May 20, 2024 · 6 min read

Adding the following markup in the “Edit Markup” section in Community Builder will fix the issue of mapping and generating the JWT (JSON Web Token) with the Lightning Viz component to the Tableau server.

This issue apparently is only related to the Lightning Viz component when used in Lightning (Experience Cloud) communities.

Paste this markup into the community's Edit Markup section (Community Builder → Settings → Advanced → Edit Head Markup). It patches the missing resource mapping so the component can call the Tableau JWT and EAS endpoints.

The fix

<!-- START - TEMP FIX FOR MISSING MAPPING -->
<script>
    var prefix = "/services/data/v60.0";
    var prev = Object.defineProperty;
    var tempMapping = {
        // POST method for generating the custom Tableau embedding JWT
        'TableauEmbeddingController.postJWT': {
            urlPath: prefix + '/tableau/jwt',
            urlPathParamNames: [],
            method: 'POST',
            inputRepresentation: 'tableauJwtArgs'
        },
        // GET method to retrieve the custom Tableau embedding JWT
        'TableauEmbeddingController.getJWT': {
            urlPath: prefix + '/tableau/jwt',
            urlPathParamNames: [],
            method: 'GET',
        },
        // Get the Tableau EAS trust details
        'TableauEmbeddingController.getEAS': {
            urlPath: prefix + '/tableau/eas',
            urlPathParamNames: [],
            method: 'GET',
        }
    };
    Object.defineProperty = (obj, prop, descriptor) => {
        if (obj.getResourceReferenceFromAuraMethod) {
            var oldGetResourceReferenceFromAuraMethod = obj.getResourceReferenceFromAuraMethod;
            obj.getResourceReferenceFromAuraMethod = (name) => {
              return tempMapping[name] || oldGetResourceReferenceFromAuraMethod(name);
            };
        }
        prev(obj, prop, descriptor);
    }
</script>
<!-- END - TEMP FIX FOR MISSING MAPPING -->

How it works

The script temporarily overrides Object.defineProperty to inject a mapping for the Tableau embedding controller methods that are otherwise missing in the community context. It supplies the URL paths and HTTP methods for:

  • TableauEmbeddingController.postJWT — POST to generate the custom Tableau embedding JWT.
  • TableauEmbeddingController.getJWT — GET to retrieve the JWT.
  • TableauEmbeddingController.getEAS — GET the Tableau EAS (External Authorization Server) trust details.

When the Aura framework asks for a resource reference for one of these methods, the patched getResourceReferenceFromAuraMethod returns the mapping we defined; for anything else it falls back to the original behaviour.

This is a temporary workaround. Update the API version (v60.0) to match your org, and revisit it once Salesforce ships the native mapping for the Lightning Viz component in communities.

Originally published on Cloud Mesh by Mahmood.

Back to all articles

Stuck on a Salesforce build?

Our certified team lives in the details like these. Let's get you unblocked.