Custom ui (custom panel )

Hi every one, i create simple app in glitch for pipedrive but i have a problem with parameter?
How can i get selectedIds ?

Narek

Hi @Narek_Antabyan
Let’s say we are rendering a Custom UI Panel, the context is passed via the query parameters of the Iframe URL.

https://<PANEL_IFRAME_URL>/?resource=deal&view=details&userId=13246944&companyId=10370755&selectedIds=57&id=J6ZKLfnHWW&data=true&token=eyxxxxxxxxxxxxxxxx0

yes, but how can i get it from glitch

const pipedrive = require("pipedrive");
const express = require("express");
// Load environment variables. Make sure you fill the .env file
require("dotenv").config();
  
const app = express();
app.use(express.json());
    // console.log(app)
app.use(express.static("public"));
// Callback endpoint
let x = app.get("/callback", async function (req, res) {
  const apiClient = pipedrive.ApiClient.instance;
  let oauth2 = apiClient.authentications.oauth2;
  oauth2.clientId = process.env.CLIENT_ID;
  oauth2.clientSecret = process.env.CLIENT_SECRET;
  oauth2.redirectUri = `https://${process.env.PROJECT_DOMAIN}.glitch.me/callback`;
  
  if (req.query.code) {
    try {
      const token = await apiClient.authorize(req.query.code);
      console.log("Successful Auth ✅");
      return res.status(200).redirect("/");
    } catch (error) {
      console.error("Wob, Wob, Wobb 🙁");
      return res.status(500).send(error);
    }
  } else {
    return res.status(400);
  }
});

app.listen(3000, function () {
  const d = process.env.PROJECT_DOMAIN;
  console.log(
    `🟢 App is running \nApp Panel URL: https://${d}.glitch.me/\nCallback URL: https://${d}.glitch.me/callback`
  );
});

you may use:
req.query.selectedIds in Glitch

  1. Query parametersFormat: https://someurl.glitch.me?param1=value&param2=valueYou can use the req.query property to identify URL parameters. Example code:
app.get("/", (req, res) => {
   if (req.query.selectedIds) {
      // parameter exists
      console.log(req.query.selectedIds);
   } else {
      // fallback
      console.log("selectedIds not set");
   }
}

i tred this way also, but i got nothing in logs


The selectedIds get passed in based on the resource being viewed at the time. There’s a good chance the panel systems strips out existing query parameters when it builds the Iframe URL. You shouldn’t really include them if you can. Just put your full url as the Iframe url https://ethereal-crayon.glitch.me
You may also have to deal with timeouts. Since your glitch app is sleeping when not in use, Pipedrive may say it takes too long and cancel the request (I’m just guessing based on how it handles JSON panels).

This topic was automatically closed after 10 days. New replies are no longer allowed.