How to get location information within the iframe when opening a Pipedrive integration with my app?

Hi!

I am integrating my app with Pipedrive via an iframe and facing an issue with getting context information. When opening the iframe, I only receive a URL like this:

https://my_domain/integration/pipedrive/dashboard?resource=&view=&…

However, the iframe doesn’t receive context information directly through URL parameters. I understand that I need to use the Pipedrive SDK to fetch this data, but I’m not sure how exactly to do it to retrieve the current location or context information.

Can I use methods from the app-extensions-sdk? Which specific method should I use to get location information when the iframe loads, and what needs to be done to correctly extract context once my script runs inside the iframe?

I would really appreciate any advice or examples of using the SDK!

Thanks in advance!

Hi @Anna78,
You can get contexts via URL in the following way.

const params = new URLSearchParams(window.location.search);
companyId = params.get("companyId");
userId = params.get("userId");
filter = params.get("filter");
id = params.get("id");
resource = params.get("resource");
selectedIds = params.get("selectedIds");
view = params.get("view");
excludedIds = params.get("excludedIds");

If you are talking about finding out whether it is from the deal page, contacts page or list, Pipedrive sends this with the view parameter. You can edit your view accordingly if you want.

You can catch this in your endpoint before opening the HTML page and perform operations beforehand.

const {companyId, userId ,filter, id, resource, selectedIds, view, excludedIds } = req.query;

if (!companyId || !userId || !filter || !id || !resource || !view) {
return res.status(400).send("Invalid request");
}

res.render("page")

An example for NodeJS express.

1 Like