Creating a reminder about task end date using a script

You can create a reminder about a task end date using the script below. After its execution, a user will receive a notification which specifies a task and the time remaining until its end. The task to remind of will be stored in a context variable.

For the script to work correctly, add libraries:
EleWise.ELMA.Documents.Docflow
EleWise.ELMA.Projects
EleWise.ELMA.CRM

Namespaces:

using EleWise.ELMA.Common.Models;
using EleWise.ELMA.Model.Common;
using EleWise.ELMA.Model.Entities;
using EleWise.ELMA.Model.Entities.EntityReferences;
using EleWise.ELMA.Model.Managers;
using EleWise.ELMA.Model.Types.Settings;
using EleWise.ELMA.Tasks.Models;
using EleWise.ELMA.Model.Services;
 

Script:

var r = ReferenceOnEntity.Create(context.Task); //create a link to a task      
var rem = InterfaceActivator.Create<Reminder>(); //create a reminder
rem.RefObject = r; //link to the task to remind of
rem.RemindDate = context.SendTime; //time to send the reminder at
rem.RemindTo = context.Interval; //time left until the task end, which is specified in the reminder
rem.PropertyName = "StartDate"; //for a task it may be StartDate or EndDate
rem.Save(); //save the reminder
 
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here

 

 

Namespace:.

using EleWise.ELMA.Model.Entities;
 

Script:

var r = ReferenceOnEntity.Create(context.Task); //create a link to a task        
var rem = PublicAPI.Portal.Objects.Common.Reminder.Create(); //create a reminder
rem.RefObject = r; //link to the task to remind of
rem.RemindDate = context.SendTime; //time to send the reminder at
rem.RemindTo = context.Interval; //time left until the task end, which is specified in the reminder
rem.PropertyName = "StartDate"; //for a task it may be StartDate or EndDate
rem.Save(); //save the reminder