Skip to main content

executeAction()

Last updated 14/06/2022


Example One

The following code executes an action on the Five server to send a leave request email to management.


executeAction()
function sendLeaveRequestEmail(five: Five, context: any, result: FiveError): FiveError {
const emailContext: any={};
emailContext['name']='Bill Watts';
emailContext['email']='bill@gmail.com';
emailContext['subject']='Request for leave';

const executeResult = five.executeAction('LeaveRequest', emailContext);
if (executeResult.isOk() === false) {
return five.createError(executeResult, 'Failed to send email');
}
}


Example Two

The following code executes an action using the optional At paramater on the Five server to send a leave request email to management 24 hours later.


executeAction() using the optional At parameter.
function sendLeaveRequestEmail(five: Five, context: any, result: FiveError): FiveError {
const emailContext: any={};
emailContext['name']='Bill Watts';
emailContext['email']='bill@gmail.com';
emailContext['subject']='Request for leave';

let timeToSend = new Date();
timeToSend.setDate(timeToSend.getDate() + 1);

const executeResult = five.executeAction('LeaveRequest', emailContext, timeToSend);
if (executeResult.isOk() === false) {
return five.createError(executeResult, 'Failed to send email');
}
}