AnsweredAssumed Answered

Add an AFContact to a Notification Rule Error: DeliveryChannel Has Not Been Defined

Question asked by BrianHollaway on Jun 23, 2020
Latest reply on Jun 24, 2020 by BrianHollaway

The below code results in an error:


'Cannot set 'ContactTemplate' property for Notification Rule Subscriber 'Test' in Notification Rule 'High Kp Index' in Element 'Kp Indices' in Element 'GIC' because a DeliveryChannel has not been defined.'



PISystems AFSyss = new PISystems();
PISystem AFsys = AFSyss["AFServer"];
AFDatabase AFDB = AFsys.Databases["Database"];


OSIsoft.AF.Search.AFElementSearch elementquery = new OSIsoft.AF.Search.AFElementSearch(AFDB, "ElementSearch", "Root:'GIC' Name:'Kp*'");AFNamedCollectionList<AFContact> AFcontacts = OSIsoft.AF.Asset.AFElement element = elementquery.FindObjects(0, true).First();


AFContact.FindContacts(AFsys, "User1*", AFSearchField.Name, AFSortField.Name, AFSortOrder.Descending, 100);
OSIsoft.AF.Notification.AFNotificationContactTemplate cT = new OSIsoft.AF.Notification.AFNotificationContactTemplate(AFcontacts[0], "Test");


This code generally follows the example found in


AFNotificationContactTemplate Class 


Although the example uses AFNotifications instead of AFNotificationRules.


What is the right way to add a contact that is found using FindContacts to an existing Notification Rule?