Skip to main content

sendNotification()

Last updated 12/09/2024

Example One

The following code will send a notification to the current logged in user using

sendNotification()
and will be available in the Notifications bell to display in the UI.

Send a notification to self
function RequestQuote(five: Five, context: any, result: FiveError) : FiveError  {
five.sendNotification(five.currentUserKey(), `You're request has been sent. One of our sales people will be in touch shortly.`);
return five.success(result);
}

Example Two

The following code will send a notification to another user, in this example, the user with the user ID bob.

Send a notification to another user
function SendThanksDelivery(five: Five, context: any, result: FiveError) : FiveError {
const sql = `SELECT iUserKey FROM iUser WHERE UserID = ?`;
const queryResult = five.executeQuery(sql, 0, 'bob');
if (queryResult.isOk() === true) {
const userKey = queryResult.records[0].iUserKey;
five.sendNotification(userKey, `Thanks for dispatching the delivery Bob.`);
}

return five.success(queryResult);
}