AnsweredAssumed Answered

FindElementAttributes not returning attributes with the property isExcluded even if ShowExcludedAttributes = true

Question asked by OleADS on Oct 10, 2019
Latest reply on Oct 11, 2019 by OleADS

Hi, 

 

I'm pretty new to the developping in c# and with the AF SDK. I'm trying to get a list of all the ElementAttributes I have in all elements called "Datasource" and set the isExcluded property to False if it is True. 

 

I'm using the FindElementAttributes to get all the attributes, but it does not include the Attributes tha has the isExcluded property set to True. I read some more in the documentation that the AFGlobalSettings.ShowExcludedAttributes = true, but even when this is set I still dont get the excluded attributes. Does anyone have any ideas why? 

 

my code below.

public static void RemoveAllExclusionForAttributes(AFDatabase myDb, Log Log)
{
   AFGlobalSettings.ShowExcludedAttributes = true;

   var attributes = AFAttribute.FindElementAttributes(myDb, null, "Datasource", null, null, AFElementType.Any, "*",    null, 0, true, OSIsoft.AF.AFSortField.Name, OSIsoft.AF.AFSortOrder.Ascending, 5000000);

   foreach (var attribute in attributes)
   {
      if (attribute.IsExcluded)
      {
      attribute.IsExcluded = false;
      Log.WriteToLog(String.Format("Removed the exclusion of the following attribute: {0}", attribute.GetPath()));
       }
   }
}

Outcomes