Skip to main content

Notification functions

sendMail#

The send mail function when executed sends an email to the specified recipients.

Syntax:

new NameSpace("notification").sendMail(Map emailParams);

Parameters:

ParamData typeDescription
emailParamsMapThe email configuration as map object.

Returns: Void

Example:

emailParams = {};emailParams["to"] = "some@email.com";emailParams["subject"] = "Work orders that need your attention";emailParams["message"] = "Dear User <br/> Here's a quick overview of list of work orders that has not been started since its created time.  <br/><br/> <br/>Regards, <br/>Team Facilio.";emailParams["mailType"] = "html";
new NameSpace("notification").sendMail(emailParams);
log "email sent";
// to send email with attachments
attachments = {};exportedFileDownloadURL = Module("workorder").export("open", [subject != null]);attachments["User-Guide.pdf"] = exportedFileDownloadURL; // any file download url
emailAttachmentParams = {};emailAttachmentParams["to"] = "some@email.com";emailAttachmentParams["subject"] = "Work orders that need your attention";emailAttachmentParams["message"] = "Dear User <br/> Here's a quick overview of list of work orders that has not been started since its created time.  <br/><br/> <br/>Regards, <br/>Team Facilio.";emailAttachmentParams["attachments"] = attachments;emailAttachmentParams["mailType"] = "html";
new NameSpace("notification").sendMail(emailAttachmentParams);
log "email sent with attachments";

sendSms#

The send sms function when executed sends an message to the specified recipient phone number.

Syntax:

new NameSpace("notification").sendSms(Map smsParams);

Parameters:

ParamData typeDescription
smsParamsMapThe sms configuration as map object.

Returns: Void

Example:

smsParams = {};smsParams.to = "xxxxxxxxx"; // recipient phone numbersmsParams.message = "Hello";
new NameSpace("notification").sendSms(smsParams);

sendNotification#

This function is used to send push notifications to your users. For example, send notifications whenever a new record is added. There are two examples shown below one with mandatory parameters and other example including optional parameters.

Syntax:

new NameSpace("notification").sendNotification(Number userId, Map notificationParams);

Parameters:

ParamData typeDescription
userIdNumberThe Id of user to be notified.
notificationParamsMapThe notification params as map object.

Returns: Void

Example1:

userId = 1070141;map = {};maindata = {};maindata.text = "message";// messagemaindata.title = "Final"; // titlemap.notification = maindata;map.data = maindata;log notification().sendNotification(userId,map);

Example2:

userId = 1070141;map = {};maindata = {};maindata.content_available = true;maindata.summary_id = 513615; // record idmaindata.module_name = "workorder"; // module namemaindata.text = "message"; // messagemaindata.title = "subject";maindata.priority = "high";maindata.click_action = "WORKORDER_SUMMARY";map.notification = maindata;map.data = maindata;map.application = 62;map.name = "WORKORDER_PUSH_NOTIFICATION";map.id = 513615; //record idmap.isSendNotification = true;log map;log notification().sendNotification(userId,map);

makeCall#

The makeCall function when executed sends an voice call to the specified recipient phone number.

Syntax:

new NameSpace("notification").makeCall(Map voiceCallParams);

Parameters:

ParamData typeDescription
voiceCallParamsMapThe voice call params as map object.

Returns: Void

Example:

voiceCallParams = {};voiceCallParams.to = "xxxxxxxxx"; // recipient phone numbervoiceCallParams.message = "Hello User, We are calling you from Facilio.";
new NameSpace("notification").makeCall(voiceCallParams);