<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dheeraj Varyani on Medium]]></title>
        <description><![CDATA[Stories by Dheeraj Varyani on Medium]]></description>
        <link>https://medium.com/@dheeraj_varyani?source=rss-4a605da4d374------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jThN97PHr6mgFTxFRGtWMw.png</url>
            <title>Stories by Dheeraj Varyani on Medium</title>
            <link>https://medium.com/@dheeraj_varyani?source=rss-4a605da4d374------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:48:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dheeraj_varyani/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fixing Tableau View Orientation Changes in a Mobile Publisher App and Mobile/Tableau Browsers]]></title>
            <link>https://medium.com/@dheeraj_varyani/fixing-tableau-view-orientation-changes-in-a-mobile-publisher-app-and-mobile-tableau-browsers-37fa0624e52f?source=rss-4a605da4d374------2</link>
            <guid isPermaLink="false">https://medium.com/p/37fa0624e52f</guid>
            <category><![CDATA[lwr]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[mobile-publisher]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[experience-site]]></category>
            <dc:creator><![CDATA[Dheeraj Varyani]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 18:41:43 GMT</pubDate>
            <atom:updated>2026-10-27T18:41:43.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZ3MyV97WMx8wJwIqNXb3A.png" /></figure><p>How the attached script keeps a Tableau dashboard in sync with the available space on mobile and tablet devices.</p><p>I was working with the standard Tableau View component on an Experience Cloud page used for a Mobile Publisher app.</p><p>The dashboard was loading, but when the device orientation changed from portrait to landscape, the Tableau content was not using the available width properly. There was also extra space on the left and right.</p><p>The head-markup script below worked for my page. It handles loading, orientation changes, dashboard sizing, and the extra horizontal spacing together.</p><h3>Why resizing the page was not enough</h3><p>The page and the outer iframe could become wider while the dashboard inside kept its previous size.</p><p>The script handles both parts. It asks the Tableau embed to resize, then applies the current container dimensions to the active dashboard through the Tableau API.</p><p>It does not read or change the cross-origin iframe document.</p><h3>First, it waits for Tableau to be ready</h3><p>A script loaded from Experience Builder head markup can run before the Tableau component has finished loading. Finding the page does not mean the dashboard is ready.</p><p>The waitForTableau() function checks for the standard component, its exposed shadow root, the tableau-viz element, the resize() method, and the active dashboard.</p><p>It also handles the workbook getter temporarily being unavailable while Tableau loads. Instead of stopping at the first missing element, it checks again after 250 milliseconds.</p><p>This wait is limited to 120 seconds. If the dashboard is still unavailable, the script stops checking and records a timeout with the readiness details.</p><p>Once the component and dashboard are ready, install() sets up the spacing adjustment, the size observer, and the event listeners.</p><h3>It responds to orientation and layout changes</h3><p>The script listens for window resize, orientationchange, and the screen orientation change event where it is available.</p><p>It also uses a ResizeObserver on the Tableau container. This matters because the space available to the dashboard can change when the surrounding page layout changes, even without rotating the device.</p><p>All these events use the same schedule() function. That function clears the previous timers and schedules resize checks after 200 and 800 milliseconds.</p><p>This gives the mobile layout some time to settle. The second check can pick up a later size change. If the dimensions have not changed, the script skips applying the same size again.</p><h3>It measures the space instead of using fixed mobile widths</h3><p>The resize() function reads clientWidth and clientHeight from the Tableau view’s parent element.</p><p>It then calls viz.resize() and uses changeSizeAsync() on the active dashboard. The behavior is exactly, with the measured dimensions supplied as both minSize and maxSize.</p><p>Here, exactly does not mean one fixed width for every device. It means the dashboard is set to the exact size available at that moment. The next orientation change causes a new measurement and a new size.</p><p>The script also checks that the view is still connected to the page and that the container has a non-zero size before resizing it.</p><p>The height comes from the existing container too. On my page, that height was 1000 pixels. The script kept it, so the dashboard still needed vertical scrolling. It does not force the entire dashboard into the visible screen height.</p><h3>It avoids overlapping resize requests</h3><p>Rotating a device can trigger several events close together. The script uses running and rerun flags so it does not start another dashboard size request while one is already running.</p><p>If another resize check is requested during that time, it checks the current dimensions again after the first request finishes.</p><p>It also remembers the last successfully applied width and height. This avoids repeating the same dashboard request when several events report the same size.</p><h3>It reduces the empty space on the left and right</h3><p>The extra space was not all inside Tableau. The surrounding column had horizontal padding, and the Tableau placeholder had an extra right margin.</p><p>The removeOuterSpacing() function reads the column’s actual left and right padding. It extends only the Tableau host into that space using matching negative margins.</p><p>It also removes horizontal margin and padding from the Tableau article and placeholder. It does not remove the column padding for other components on the page.</p><p>After adjusting the spacing, the script measures the container again before resizing the dashboard.</p><p>In the mobile emulation test, the dashboard used the full 375-pixel width in portrait and 667-pixel width in landscape. Returning to portrait also worked. These are test results, not hardcoded widths. A small inset remained within the workbook’s own layout.</p><h3>It supports restarting and stopping</h3><p>The first line stops an existing window.tableauAutoResize instance before starting another one. This prevents duplicate event listeners when the script is loaded again in the same page context.</p><p>The stop() method cancels the pending initialization and resize timers, disconnects the observer, and removes the event listeners.</p><p>Before changing the outer styles, the script saves the original inline styles. Stopping restores those styles. It does not undo the last dashboard size applied through the API; reloading the page resets that runtime sizing.</p><h3>How I added it to the page</h3><ol><li>Saved the complete script below as a JavaScript file.</li><li>Uploaded the file as a static resource.</li><li>Referenced the resource from Experience Builder head markup.</li><li>Reloaded the page and checked portrait to landscape, then landscape back to portrait.</li></ol><p>The script is written for the standard component structure used on this page. It needs access to that component’s exposed shadow root. A different loading context or a closed shadow root may require a different integration approach.</p><h3>How to check its status</h3><p>The controller is available as window.tableauAutoResize.</p><ul><li>status shows waiting, ready, timeout, or stopped.</li><li>diagnostics shows whether the host, shadow root, view, resize method, and active dashboard were found.</li><li>history records successful resize calls, including the viewport, container, view dimensions, and the dashboard API result.</li><li>resize() schedules a fresh resize check.</li><li>stop() removes the handlers and restores the outer styles.</li></ul><p>This makes it easier to tell whether the script is still waiting for Tableau or has already started handling size changes.</p><h3>The complete working script</h3><p>This is the head-markup script I created and used inside the Static Resource (js file) and attached in the head-markup.</p><pre>/* Experience Builder head-markup version. Waits for the standard component<br>   and its loaded dashboard before installing the previously tested resizer. */<br>// Still depends on this context being allowed to access the open host root.<br>(() =&gt; {<br>  window.tableauAutoResize?.stop();<br>  let initializationTimer;<br>  let cancelled = false;<br>  let stopActive;<br>  const startedAt = Date.now();<br>  const controller = {<br>    status: &#39;waiting&#39;,<br>    diagnostics: {},<br>    history: [],<br>    resize() {},<br>    stop() {<br>      cancelled = true;<br>      clearTimeout(initializationTimer);<br>      stopActive?.();<br>      controller.status = &#39;stopped&#39;;<br>    }<br>  };<br>  window.tableauAutoResize = controller;<br>  function waitForTableau() {<br>    if (cancelled) return;<br>    let host, root, viz, sheet;<br>    let accessError;<br>    try {<br>      host = document.querySelector(&#39;tableau-tableau-viz&#39;);<br>      root = host?.shadowRoot;<br>      viz = root?.querySelector(&#39;tableau-viz&#39;);<br>      // The workbook getter may throw until Tableau is interactive.<br>      sheet = viz?.workbook?.activeSheet;<br>    } catch (error) {<br>      accessError = error.name;<br>    }<br>    controller.diagnostics = {<br>      hostFound: Boolean(host),<br>      shadowRootVisible: Boolean(root),<br>      vizFound: Boolean(viz),<br>      resizeAvailable: typeof viz?.resize === &#39;function&#39;,<br>      dashboardReady: sheet?.sheetType === &#39;dashboard&#39;,<br>      ...(accessError ? { accessError } : {})<br>    };<br>    if (controller.diagnostics.resizeAvailable &amp;&amp;<br>        controller.diagnostics.dashboardReady) {<br>      controller.status = &#39;ready&#39;;<br>      install(host, viz);<br>      console.log(&#39;TABLEAU_READY&#39;);<br>      return;<br>    }<br>    if (Date.now() - startedAt &gt;= 120000) {<br>      controller.status = &#39;timeout&#39;;<br>      console.error(<br>        &#39;TABLEAU_INIT_TIMEOUT&#39;,<br>        JSON.stringify(controller.diagnostics)<br>      );<br>      return;<br>    }<br>    initializationTimer = setTimeout(waitForTableau, 250);<br>  }<br>  function install(host, viz) {<br>  // Remove the measured outer spacing for this Tableau component only.<br>  const placeholder = viz.parentElement;<br>  const card = placeholder.parentElement;<br>  const column = host.assignedSlot?.parentElement;<br>  const originalStyles = new Map(<br>    [host, placeholder, card].map(element =&gt; [element, element.getAttribute(&#39;style&#39;)])<br>  );<br>  function removeOuterSpacing() {<br>    const columnStyle = column ? getComputedStyle(column) : null;<br>    const left = parseFloat(columnStyle?.paddingLeft) || 0;<br>    const right = parseFloat(columnStyle?.paddingRight) || 0;<br>    // Extend only this host into its column gutters; preserve sibling layout.<br>    host.style.setProperty(&#39;display&#39;, &#39;block&#39;, &#39;important&#39;);<br>    host.style.setProperty(&#39;width&#39;, &#39;auto&#39;, &#39;important&#39;);<br>    host.style.setProperty(&#39;max-width&#39;, &#39;none&#39;, &#39;important&#39;);<br>    host.style.setProperty(&#39;margin-left&#39;, `${-left}px`, &#39;important&#39;);<br>    host.style.setProperty(&#39;margin-right&#39;, `${-right}px`, &#39;important&#39;);<br>    for (const element of [placeholder, card]) {<br>      for (const side of [&#39;left&#39;, &#39;right&#39;]) {<br>        element.style.setProperty(`margin-${side}`, &#39;0px&#39;, &#39;important&#39;);<br>        element.style.setProperty(`padding-${side}`, &#39;0px&#39;, &#39;important&#39;);<br>      }<br>    }<br>  }<br>  removeOuterSpacing();<br>  let timer;<br>  let settleTimer;<br>  let calls = 0;<br>  let running = false;<br>  let rerun = false;<br>  let stopped = false;<br>  let lastSize = &#39;&#39;;<br>  const history = [];<br>  async function resize() {<br>    if (running) { rerun = true; return; }<br>    running = true;<br>    try {<br>      do {<br>        rerun = false;<br>        if (stopped || !viz.isConnected) return;<br>        removeOuterSpacing();<br>        const width = viz.parentElement.clientWidth;<br>        const height = viz.parentElement.clientHeight;<br>        if (!width || !height) return;<br>        const key = `${width}x${height}`;<br>        if (key === lastSize) continue;<br>        const sheet = viz.workbook?.activeSheet;<br>        if (sheet?.sheetType !== &#39;dashboard&#39;) {<br>          throw new Error(&#39;Wait for the Tableau dashboard to finish loading.&#39;);<br>        }<br>        viz.resize();<br>        const size = { width, height };<br>        const dashboard = await sheet.changeSizeAsync({<br>          behavior: &#39;exactly&#39;, minSize: size, maxSize: size<br>        });<br>        lastSize = key;<br>        const result = {<br>          call: ++calls,<br>          viewport: [window.innerWidth, window.innerHeight],<br>          container: [width, height],<br>          viz: [viz.clientWidth, viz.clientHeight],<br>          dashboard<br>        };<br>        history.push(result);<br>        console.log(&#39;TABLEAU_RESIZE&#39;, JSON.stringify(result));<br>      } while (rerun);<br>    } catch (error) {<br>      console.error(&#39;TABLEAU_RESIZE_FAILED&#39;, error);<br>    } finally {<br>      running = false;<br>    }<br>  }<br>  function schedule() {<br>    clearTimeout(timer);<br>    clearTimeout(settleTimer);<br>    timer = setTimeout(resize, 200);<br>    settleTimer = setTimeout(resize, 800);<br>  }<br>  const observer = new ResizeObserver(schedule);<br>  observer.observe(viz.parentElement);<br>  window.addEventListener(&#39;resize&#39;, schedule);<br>  window.addEventListener(&#39;orientationchange&#39;, schedule);<br>  window.screen.orientation?.addEventListener(&#39;change&#39;, schedule);<br>  controller.history = history;<br>  controller.resize = () =&gt; { lastSize = &#39;&#39;; schedule(); };<br>  stopActive = () =&gt; {<br>      stopped = true;<br>      clearTimeout(timer);<br>      clearTimeout(settleTimer);<br>      observer.disconnect();<br>      window.removeEventListener(&#39;resize&#39;, schedule);<br>      window.removeEventListener(&#39;orientationchange&#39;, schedule);<br>      window.screen.orientation?.removeEventListener(&#39;change&#39;, schedule);<br>      for (const [element, style] of originalStyles) {<br>        if (style === null) element.removeAttribute(&#39;style&#39;);<br>        else element.setAttribute(&#39;style&#39;, style);<br>      }<br>  };<br>  schedule();<br>  }<br>  waitForTableau();<br>})();</pre><p>The main point is to wait until Tableau is ready, measure the space after the layout changes, and resize the dashboard itself. That is what made this work for my page.</p><p>References: <a href="https://help.tableau.com/current/api/embedding_api/en-us/docs/embedding_api_configure.html">Tableau embed dimensions and resizing</a> and <a href="https://help.tableau.com/current/api/embedding_api/en-us/reference/interfaces/Dashboard.html">Tableau dashboard API</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37fa0624e52f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Display Classic content (like Visualforce pages) in Lightning Experience]]></title>
            <link>https://medium.com/@dheeraj_varyani/display-classic-content-like-visualforce-pages-in-lightning-experience-1a2cac5c0a53?source=rss-4a605da4d374------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a2cac5c0a53</guid>
            <category><![CDATA[salesforce-development]]></category>
            <category><![CDATA[salesforce-classic]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[salesforce-visualforce]]></category>
            <category><![CDATA[salesforce-lightning]]></category>
            <dc:creator><![CDATA[Dheeraj Varyani]]></dc:creator>
            <pubDate>Sun, 15 Sep 2024 08:51:45 GMT</pubDate>
            <atom:updated>2024-09-15T08:51:45.814Z</atom:updated>
            <content:encoded><![CDATA[<h4>Salesforce Dev Hacks — Part 1</h4><h3>What is anyway need for opening a Classic content (such as Visualforce page/classic record page) over Lightning Experience?</h3><p>We need to do so as by doing so we will have the access of the Lightning Experience features (such as App Launcher, Global Search over the App, Global Actions, App Builder, etc.)</p><h3>How can we access Visualforce Page on Lightning Experience?</h3><p>There are 2 method be can access Visualforce Pages in Lightning Experience, be it a in the format of <strong>PDF </strong>or <strong>Classic </strong>or <strong>using Lightning Out.</strong></p><h4>Methods to Access Visualforce Pages in Lightning Experience</h4><p>There are a few approaches to make your Visualforce pages accessible within the Lightning framework :-</p><h4><strong>1. Direct Navigation Using URLs</strong></h4><p>One of the most straightforward ways to access a Visualforce page in Lightning is by directly navigating to it via its URL. <br>Here’s how:<br> Every Visualforce page has a unique URL, even within Lightning Experience. <br><strong>The traditional URL looks like this:</strong></p><pre>https://{yourinstance.salesforce.com}/apex/{YourVisualforcePage}</pre><p>Or we can just use,</p><pre>/apex/{YourVisualforcePage}</pre><h4>2. Using the NavigationMixin to Navigate from a Lightning Component</h4><figure><img alt="Embedded Video — Display Classic content (like Visualforce pages) in Lightning Experience" src="https://cdn-images-1.medium.com/max/1024/1*YHx7npMDqYz-FjNdDQ-DJg.gif" /><figcaption>In the video, I have created an LWC component used Lightning Card action button to Navigate to the New Lightning-Classic Superimposed URL</figcaption></figure><p>For a more integrated experience, you can use the NavigationMixin in a Lightning component to navigate to the Visualforce page programmatically. Here&#39;s a sample code snippet that does this :</p><pre>let urlParams = {<br>    componentDef:&quot;one:alohaPage&quot;,<br>    attributes:{<br>        address:&quot;/apex/{YourVisualforcePage}&quot;<br>    },<br>    state:{}<br>};<br><br>this[NavigationMixin.Navigate]({<br>    type: &#39;standard__webPage&#39;,<br>    attributes: {<br>        url: `/one/one.app#${btoa(JSON.stringify(urlParams))}`, // can prepend with - https://{yourinstance.salesforce.com}<br>    },<br>});</pre><h4>Breakdown of Code:</h4><ul><li><strong>Creating URL Parameters</strong>: The urlParams variable constructs the JSON necessary to navigate to a Visualforce page, specifying the component definition (one:alohaPage), it specifies that you want to navigate to an Aloha page, which is a way to display Classic content (like Visualforce pages) in Lightning Experience and adding address in the attributes with Visualforce page’s URL (/apex/{YourVisualforcePage}).</li></ul><pre>let urlParams = {<br>    componentDef:&quot;one:alohaPage&quot;,<br>    attributes:{<br>        address:&quot;/apex/{YourVisualforcePage}&quot;  // can append with &quot;?id={specify_record_Id}&quot; for passing paramenters in Vf page<br>    },<br>    state:{}<br>};</pre><ul><li><strong>Encoding the URL</strong>: The btoa(JSON.stringify(urlParams)) function encodes the URL parameters into Base64 format.</li><li><strong>Navigation Using </strong><strong>NavigationMixin</strong>: Finally, the NavigationMixin.Navigate method directs users to the Visualforce page within the Lightning Experience framework, ensuring a smooth user transition.</li></ul><p>This method is highly preferred because it maintains the Lightning UI structure while accessing the Visualforce page.</p><h4>3. Embedding Visualforce Pages within Lightning Components</h4><p>Salesforce provides the ability to embed Visualforce pages directly into Lightning components (Aura) using the &lt;lightning:container&gt; tag. This can be useful when you want to mix Lightning and Visualforce on the same page or application.</p><pre>&lt;lightning:container src=&quot;/apex/YourVisualforcePage&quot; /&gt;</pre><h4>4. Adding Visualforce Pages to the Lightning App Builder</h4><p>Visualforce pages can be added to the Lightning App Builder as custom tabs or components.</p><p>Steps:</p><ol><li>Navigate to the <strong>Lightning App Builder</strong>.</li><li>Drag the <strong>Visualforce</strong> component from the standard components list to the page layout.</li><li>Select the specific Visualforce page you want to embed.</li></ol><p>This method is great when you want to integrate your Visualforce page as part of a more comprehensive Lightning page, mixing Lightning components and Visualforce content.</p><h4>5. Using Lightning Tabs</h4><p>You can also add a Visualforce page as a custom tab in your Lightning app:</p><ol><li>Go to <strong>Setup</strong> &gt; <strong>Tabs</strong>.</li><li>In the App Settings, navigate to <strong>Navigation Items</strong> and select <strong>Visualforce Tabs</strong>.</li><li>Choose the specific Visualforce page you want to make available.</li></ol><p>This method provides a native way to access a Visualforce page from within your Lightning app without disrupting the user experience.</p><p>I hope you enjoyed this article and found it helpful in understanding how to access Visualforce pages within Salesforce Lightning Experience ⚡.</p><p>Whether you’re maintaining legacy functionality or building new features, integrating Visualforce with Lightning ensures your users benefit from both custom UIs and the modern Lightning experience 💻✨.</p><p>If you have any questions, feel free to reach out or explore more Salesforce development topics on this blog 🚀.</p><p>Happy coding, and may your Salesforce journey be smooth and successful! 🎉🌟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a2cac5c0a53" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>