Creating a custom data type for a list of notification recipients
This article illustrates an example of creating a custom data type for the list of notification recipients. There are many data types for the list of notification recipients in the system. You can find information about these data types here. This example demonstrates how to create a data type, which receives a user group and then selects all the users of these group and adds them to the list of notification recipients.
Use-case
<RecipientSet>
<Group>{$New.UserGroup}</Group> <!-- Where New is your object, and UserGroup is the object's property of the User Group type -->
</RecipientSet>
Interface Methods
/// <summary>
/// Name of the message recipient type (according to the name in the template)
/// </summary>
string Name { get; }
/// <summary>
/// Get the list of recipients (users)
/// </summary>
/// <param name="value">Value</param>
/// <returns>List of recipients (users)</returns>
IEnumerable<object> GetRecipients(object value);
Example of implementation of an extension point (interface)
[Component]
public class GroupNotificationType : INotificationRecipientTypeHandler
{
public string Name
{
get { return "Group"; }
}
public IEnumerable<object> GetRecipients(object value)
{
if (value == null)
{
return new object[0];
}
var group = value as IUserGroup;
if (group != null)
{
var recipients = new List<object>();
if (group.Users.Count > 0)
{
foreach (var user in group.Users)
{
recipients.Add(user);
}
return recipients;
}
}
return new object[0];
}
}
Note
You can use any object type when implementing an extension point, e.g. an object, task type, project, relationship and so on. When implementing this extension point, most importantly, you must compile a list of users, who will receive a notification.