Skip to content
// Proposal status for the owner (no HTML, no token): by ?id=, or the latest one for ?email=.
const q = $('Status API').first().json.query ?? {};
const all = Object.values($getWorkflowStaticData('global').proposals ?? {});
const p = q.id ? all.find((x) => x.id === String(q.id))
  : all.filter((x) => x.lead.email === String(q.email ?? '').toLowerCase()).sort((a, b) => (a.created_at < b.created_at ? 1 : -1))[0];
if (!p) return [{ json: { found: false, id: q.id ?? null, email: q.email ?? null } }];
const { html, token, text, ...rest } = p;
return [{ json: { found: true, ...rest } }];