sendNotification()
Last updated 12/07/2022
Example One
The following code will send a notification to the current logged in user and will display in the UI.
Send a notification to self
function requestQuote(five: Five, context: any, result: FiveError) : FiveError {
const userKey = five.currentUserKey();
five.sendNotification(userKey, `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 sendNotificationToAUser(five: Five) : 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, `Hello Bob.`);
}
return five.success(queryResult);
}