logo

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.

Script with PublicAPI

Note
Documentation on PublicAPI is available here
Attention
The script below is relevant for ELMA up to 3.12.1 inclusive.

Namespace:

using EleWise.ELMA.Model.Entities.EntityReferences;

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

Script without PublicAPI

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

Namespaces:

using EleWise.ELMA.Common.Models;
using EleWise.ELMA.Model.Entities.EntityReferences;
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