1. Notification to users added to multiple user reference column

    Article: AN0002406Updated: 23.12.2019

    In some cases we need to send a notification to users that were added to column of type multiple reference to user. We want to send the notification only to newly added users, not those that were included in the column before.

    For this we can use well rule of type Script. One rule After saving a new record and one rule After saving an existing record. Below stated rules will send this notification 'new-team-member' one by one to all newly added users in column project-team.

    You were added to the project team of project {{column.code}}: {{column.name}}.

    Project manager: {{column.project_manager}}
    Description: {{column.description}}

    Link: {{var.datarow.url}}
    -----------------------------------------------------------------------------
    Do not reply to this email. It is generated automatically.

     

    Rule of type Script - After saving a new record.

    var personNew = OGActualDataRow['project-team'];

    //projit uzivatele v project-team
    for( var i = 0; i < personNew.Count; ++i)
    {
    var p = personNew[i];
    var m = OG.Email.CreateMessage();
    m.AssignEmailForDataRow = OGActualDataRow;
    m.Notification = OG.Notification.GetAll().GetDefaultByCode( OGDataParent.ModelId, 'new-team-member');
    m.AddTo(p);

    //adding varible used in the notification
    m.AddVariable('datarow.url', OG.GetWebUrl() + '' + OGActualDataRow.DetailUrl);

    OG.Email.Send(m);
    }

     

    Rule of type Script - After saving an existing record.

    var personOld = OGOldDataRow['project-team'];
    var personNew = OGActualDataRow['project-team'];

    //go through users and select only those from new, that are not in old
    for( var i = 0; i < personNew.Count; ++i)
    {
    var p = personNew[i];
    if ( !personOld.Contains(p.Id))
    {
    var m = OG.Email.CreateMessage();
    m.AssignEmailForDataRow = OGActualDataRow;
    m.Notification = OG.Notification.GetAll().GetDefaultByCode( OGDataParent.ModelId, 'new-team-member');
    m.AddTo(p);

    //adding varible used in the notification
    m.AddVariable('datarow.url', OG.GetWebUrl() + '' + OGActualDataRow.DetailUrl);

    OG.Email.Send(m);
    }
    }

    The sent email will be shown in the Detailed archive of the record, in which project team members were added.

×