Skip to main content

addCallback(callbackKey, callbackFn)

Adds a callback function to CommandBar.See this doc that talks about how callback actions work.

Example

window.CommandBar.addCallback(
"sayHi",
// Assumes an argument called "name"
(args, context) => alert(`Hi there, ${args.name}!`)
);

Method parameters

callbackKey Required

string

Key to reference the provided function

callbackFn Required

function

Callback function, with the following signature:

ArgsTypeDescription
argsobjectA dictionary of argument keys and the values entered by the user
contextobjectA dictionary reflecting the state of context when the callback was triggered by an action being executed