function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ron McKnight 5Ron McKnight 5 

Passing field values to lightning component iframe

Is it possible to pass a field value from a record to an iframe hosted inside a lightning component?

I have built an iframe inside a lightning component. The iframe is a link to a database that contains rows of records that are related to the Account object in Salesforce, but only lives in the database, not salesforce.

What I am trying to do is pass the value of a field called account number into the url of the iframe, so that the values presented in the iframe are sorted according to the field value being presented by the current active record in salesforce.
DimondDimond
yes, you should be able to unless i'm missing something here. Have you tried it?
Ron McKnight 5Ron McKnight 5
I have attempted to do so but can't seem to get the right combination of javascript down. I read somewhere that post.mesage() functions might work but I went this route:
js code:
 
var recordId = account.Page.data.entity.getId();
branchId_c = recordId.replace("{","").replace("}","");
branchId_c = recordId.toLowerCase();
Xrm.Page.ui.controls.get("IFRAME_iFrame_Test").setSrc("https://COMPANYADDRESS.com/SDM/SDM.aspx?
view=viewer&categoryId=4&dashboard=WS_CRM_Sample&filters=Company.Company_Name&filterVal
ues="+recordId);
}

Ligntning iframe component looks like:

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
	<aura:attribute name="iframeUrl" type="String" />
    <aura:attribute name="width" type="String" />
    <aura:attribute name="height" type="String" />
    <aura:attribute name="scrolling" type="String" />
    <aura:attribute name="frameBorder" type="String" />
    <aura:attribute name="style" type="String" />
    <aura:attribute name="sandbox" type="String" />
    
    <iframe src="{!v.iframeUrl}"
            width="{!v.width}"
            height="{!v.height}"
            style="{!v.style}"
            frameBorder="{!v.frameBorder}"
            sandbox="{!v.sandbox}"
            scrolling="{!v.scrolling}"/>
</aura:component>

 
DimondDimond
whats showing in the iframe? where is the attribute being set?
Ron McKnight 5Ron McKnight 5
This is what is showing in the iframe:
User-added image

The Branch, 7G Distributing, has a field called Branch ID. It is a unique 7 digit number. I want to filer the list in the iframe by using that 7 digit number. Of the 47 items displayed in the iframe, only 1 of those records relates to the current Branch/Account in the active salesforce window. So, that is why I'm trying to filter the list by Branch ID each time a Branch is loaded (accessed) in salesforce.

I am calling the url from the component as: https://analytics.pabst.com/SDM/SDM.aspx?ds=MM_Web&view=viewer&categoryId=0&dashboard=SF+Widget+Test&filters=Wholesaler.Branch&filtervalues=4225704"  noborders="0" width="950" height="700" scrolling="no" seamless></iframe>&hideTopBar=true
DimondDimond
good news, the value is being passed. something looks a little strange in the url, filter is set to name but you're passing id...hmmm