Overview The Pivot 2.0 API exposes a cellClick event that fires whenever a user clicks a cell, handing to script the full cell context. This short guide uses that event to add a small convenience: click any cell and its value is copied straight to the clipboard, with a brief toast to confirm. The implementation is intentionally minimal. One event handler plus two small helpers. Availability: The Pivot 2.0 API (including cellClick) is available in Sisense L8.2.1 and later , on Linux versions, and only for Pivot 2.0 widgets. Step-by-step guide Open your Pivot 2.0 widget and click Edit Script (the pencil / script icon in the widget menu). Paste the script below into the editor. Click Apply , save the dashboard, and refresh. Clicking any cell now copies its value and shows a confirmation toast. widget.on("cellClick", function (widget, eventData) {
const value = eventData?.metadata?.cellData?.content;
if (value === undefined || value === null || value === "") {
return;
}
if (typeof value !== "string") {
console.error(
"[pivot2-copy] Expected cell content to be a string, got " +
typeof value + ":",
value
);
return;
}
copyToClipboard(value).then(function (ok) {
if (ok) {
showToast("Copied: " + value);
} else {
console.error("[pivot2-copy] Failed to copy cell value to clipboard");
}
});
});
// --- helpers ---------------------------------------------------------------
// Resolves to true only when the text actually reached the clipboard.
// Prefer the async Clipboard API (requires HTTPS and, in iframe embeds,
// allow="clipboard-write"); fall back to a hidden textarea otherwise.
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text).then(
function () {
return true;
},
function () {
return legacyCopy(text);
}
);
}
return Promise.resolve(legacyCopy(text));
}
function legacyCopy(text) {
const ta = document.createElement("textarea");
ta.value = text;
ta.style.position = "fixed";
ta.style.opacity = "0";
document.body.appendChild(ta);
ta.select();
let ok = false;
try {
ok = document.execCommand("copy");
} catch (e) {
ok = false;
}
document.body.removeChild(ta);
return ok;
}
function showToast(msg) {
const id = "pivot2-copy-toast";
const existing = document.getElementById(id);
if (existing) {
existing.parentNode.removeChild(existing);
}
const el = document.createElement("div");
el.id = id;
el.textContent = msg;
el.style.cssText = [
"position:fixed",
"bottom:24px",
"left:50%",
"transform:translateX(-50%)",
"background:#2b2b2b",
"color:#fff",
"padding:8px 14px",
"border-radius:6px",
"font:13px/1.3 Arial, sans-serif",
"box-shadow:0 2px 8px rgba(0,0,0,.3)",
"z-index:99999",
"opacity:0",
"transition:opacity .15s ease",
].join(";");
document.body.appendChild(el);
requestAnimationFrame(function () {
el.style.opacity = "1";
});
setTimeout(function () {
el.style.opacity = "0";
setTimeout(function () {
if (el.parentNode) {
el.parentNode.removeChild(el);
}
}, 200);
}, 1400);
}
How it works Widget.on("cellClick", ...) fires on every cell click and passes eventData. The displayed text lives at eventData.metadata.cellData.content — that's what we copy, so it works for both value cells (the number) and member cells (the label). Empty cells (blank grand-total corners, etc.) are ignored, and a quick type check makes sure cell content is a string, as it should be. Toast is a self-removing element fixed to the bottom of the screen confirms the copy, then fades out after ~1.4s (can be adjusted). Re-clicking replaces any existing toast so they don't stack up. A note on the Clipboard API The copy uses the modern asynchronous Clipboard API (navigator.clipboard.writeText), which is the reliable path, but it has two requirements : Secure context (HTTPS) - on plain HTTP the Clipboard API is unavailable. Embedded dashboards (iframes) need allow="clipboard-write" on the iframe, or the write is blocked by permissions policy. When the Clipboard API is missing or blocked, the script falls back to the legacy approach — a hidden <textarea> plus document.execCommand("copy"). This works in more contexts (including some older embedded browsers) but is deprecated and can fail silently in others. Because both paths return their real success/failure, the toast only shows "Copied:" when the value genuinely reached the clipboard. If both paths fail, nothing is copied and a message is logged to the browser console ([pivot2-copy] Failed to copy...) rather than misleading the user with a false confirmation. Notes and limitations Pivot 2.0 / Linux / L8.2.1+ only, as noted above. The field path metadata.cellData.content reflects the current event payload; if a future version changes the shape, it should be adjusted. This copies the displayed content (formatted text), not the underlying raw numeric value. To copy the raw value target eventData.metadata.cellData.value Resources Pivot 2.0 API — cellClick event and the cell context payload: https://developer.sisense.com/guides/customJs/jsApiRef/widgetClass/pivot2.html#cellclick Widget class: https://developer.sisense.com/guides/customJs/jsApiRef/widgetClass/#widget-class