2 Replies Latest reply on Feb 17, 2017 5:47 PM by MikeSpath

    How to create e-mail groups via the AF SDK

    MikeSpath

      Hello:

      I'm using AF SDK 2016 and looking for how to programatically create an e-mail group. In PI Explorer / Contacts there is a tree structure: Contacts, Escalation Teams, Groups, Delivery Endpoints.

      I'd like to be able to create Groups and Escalation Teams. I can create contacts easy in code but struggling a bit for Groups and Escalation teams. I've been searching in the help file as well.

      Thanks,

      Mike

        • Re: How to create e-mail groups via the AF SDK
          MikeSpath

          just to tack on: below is my code that does not work.

                          var temp = AFContact.FindContacts(piSystem, descriptionIdentifier, AFSearchField.Description, AFSortField.Name, AFSortOrder.Ascending, 1000, true);

                          AFNotification myNotification = new AFNotification(db, groupname);

                          myNotification.Description = description;

                          foreach (var email in lstemail)

                          {

                              var contact = temp.Where(a => a.EMail.ToLower() ==  email.ToLower()).FirstOrDefault();

                              if (contact != null)

                              {

                                  myNotification.NotificationContacts.Add(contact, contact.EMail);

                              }

                          }

                          myNotification.CheckIn();

            • Re: How to create e-mail groups via the AF SDK
              MikeSpath

              Don't mean to answer my own question but there was an example in the help that was able to help me. I was a bit confused at first when I read the code as you have to create contact templates apparently and that becomes the group (or escalation group)

               

              // Create a Hierarchy of Notification Contact Templates

              AFNotificationContactTemplate myContactTemplate1 = new AFNotificationContactTemplate(myPISystem, "MyContact#1");

              AFNotificationContactTemplate myContactTemplate2 = new AFNotificationContactTemplate(myPISystem, "MyContact#2");

              AFNotificationContactTemplate myGroupContactTemplate = new AFNotificationContactTemplate(myPISystem, "MyGroup");

              myGroupContactTemplate.ContactType = AFNotificationContactType.Group;

              myGroupContactTemplate.NotificationContactTemplates.Add(myContactTemplate1);

              myGroupContactTemplate.NotificationContactTemplates.Add(myContactTemplate2);

               

              ....

               

              Mike