1. Automatic notifications to users outside ObjectGears

    Artikel: AN0002448Aktualisiert: 21.11.2020
    Die vorgegebene Sprachenversion vom Artikeltext wird angezeigt, weil es kein Text von der ausgewählten Sprache und Version gibt.

    In this article we will explain how we can let ObjectGears to send notifications to users who do not have ObjectGears account.

    In our example we have a class with applications (business-application) with properties support_to (date) and analysts (reference to another class ms-ad-users). Relationship of the two classes is depicted in the following scheme.

    We will use automatic time operations to check field support_to and send notification to colleagues stated in the column analysts well in advance as the date approaches.

    If there is reference to ObjectGears users in the field analysts, we could set the recipients easily in the time operation by selecting this column.

    However, notification recipients will not be ObjectGears users. Instead recipients will be represented just by records from another class at which we will have email. Sending notification can be secured by a script in a time operation above the class business-application, that will find out emails from the class ms-ad-users.

    We will set the filter in the time operation for records where the field analysts is not null. In the tab with actual operations we will use following script.

    /*the script examines the multiple classlink Analysts, that leads to class ms-ad-users - emails are in column e-mail
    It will send notification end_of_support_reminder and links the sent email to the record of the given application.*/


    var drl = OGActualDataRow.GetDR('analysts');
    if ( drl != null && drl.Count > 0)
    {
      //email preparation
      var m = OG.Email.CreateMessage();

      var isAnyEmail = false;
      for( var i = 0; i < drl.Count; ++i)
      {
        var email = drl[i]['e-mail'];
        if ( !OG.IsNull(email))
        {
          m.AddTo(email);
          isAnyEmail = true;
        }
      }

      if (isAnyEmail)
      {
        var mIt = OG.Model.GetByCode('it');
        m.Notification = OG.Notification.GetAll().GetDefaultByCode( mIt.Id, 'end_of_support_reminder');

        //linking email to the record of application
        m.AssignEmailForDataRow = OGActualDataRow;

        m.SendEmailAsOne = true; //send as a single email
        //m.SendEmailAsOne = false; //send individual emails to each recipient

        //linking email to the time operation as originator of sending
        m.OwnerType = OG.Email.EmailOwnerType_AutomaticTimeOperationSend;
        m.OwnerId = OGActualAto.Id;

        OG.Email.Send(m);
      }
    }

×