Hi,
i’m trying to embed an iframe, but i don’t get the parameters appened as described here:
https://app-eu1.hubspot.com/docs/139789941/doc/platform/create-custom-cards-with-projects#iframe
exports.main = async (context, sendResponse) => { sendResponse({ sections: [ { type: 'text', text: 'Clicking the button will open a modal dialog with an iframe that displays the content at the provided URL.', }, { type: 'button', text: 'Open iframe', onClick: { type: 'IFRAME', // Width and height of the iframe (in pixels) width: 800, height: 600, uri: "https://www.example.com.cc/senttome", associatedObjectProperties : [ 'email', ] }, }, ], });};
I would expect the following src url:
https://www.example.com.cc/senttome?email=displayed@user.com
But i get:
src=“https://www.example.com.cc/senttome#https://app-eu1.hubspot.com”
Any ideas?
Tom
Hello @reiterth73
It seems that the variables you’re trying to append to the URI of the iframe are not being included correctly. Instead of appending the variables as query parameters using the “?” symbol, it appears that the variables are being added as a fragment identifier using the “#” symbol.
you can modify the URI parameter in your code to include the query parameters correctly.
exports.main = async (context, sendResponse) => {
sendResponse({
sections: [
{
type: 'text',
text: 'Clicking the button will open a modal dialog with an iframe that displays the content at the provided URL.',
},
{
type: 'button',
text: 'Open iframe',
onClick: {
type: 'IFRAME',
// Width and height of the iframe (in pixels)
width: 800,
height: 600,
uri: "https://www.example.com.cc/senttome?email=displayed@user.com",
associatedObjectProperties : [
'email',
]
},
},
],
});
};
With this modification, the email parameter will be correctly appended to the URI as a query parameter, resulting in the following URL:
https://www.example.com.cc/senttome?email=displayed@user.com
Make sure to replace displayed@user.com with the actual email value you want to include in the URL.
@himanshurauthan thx for input.
Sure if i hardcode the parameter it works.
But i want to fill the parameter dynamically
if i click on “open iframe” the email form the current opened contact E-Mail should be appended, like described here:
Finally I found a solution which works for me:
I added “propertiesToSend” to my card defintion
{ "type": "crm-card", "data": { "title": "Info iframe", "location": "crm.record.sidebar", "fetch": { "targetFunction": "crm-card", "objectTypes": [ { "name": "contacts", "propertiesToSend": ["hs_object_id", "email", "lastname"] } ] } }}
In the serverless function i use the following code:
exports.main = async (context, sendResponse) => { sendResponse({ sections: [ { type: 'text', text: 'Clicking the button will open a modal dialog with an iframe with some parameters.', }, { type: 'button', text: 'Open iframe', onClick: { type: 'IFRAME', width: 800, height: 600, uri: "https://www.example.com?token=" + context.secrets.PRIVATE_APP_ACCESS_TOKEN + "&portal=" + context.portalId + "&user=" + context.user.userId + "&contact=" + context.propertiesToSend.hs_object_id, }, }, ], });};