2 Replies Latest reply on Jan 30, 2019 11:55 PM by natdavidson

    AF Table Column Definitions


      I'm leveraging the AF SDK in c# code, I'm trying to find how i would access the properties that are in the "Define Table" section of an AF Table in the UI. I've been able to get the "Value Type" property in code, but I can't access the "Unit Of Meausure" or "Time Zone" properties on any object.


        • Re: AF Table Column Definitions

          Hi Nate,

          Those properties of the columns are stored as extended properties of the table itself. In the example code I’ve included below, I’m calling the AFTable public method GetExtendedProperty() with the name of one of the columns in my table, along with the name of each property: “TimeZone” and “UOM”. These are both returned as strings, so if you need the actual AFTimeZone or UOM objects, you will need to retrieve them after you get the extended property values, as the code does.  I hope this helps:


          using System;

          using System.Collections.Generic;

          using System.Linq;

          using System.Text;

          using System.Threading.Tasks;

          using OSIsoft;

          using OSIsoft.AF;

          using OSIsoft.AF.Asset;

          using OSIsoft.AF.Time;

          using OSIsoft.AF.UnitsOfMeasure;


          namespace ConsoleApp1


              class Program


                  static void Main(string[] args)


                    PISystem ps = new PISystems()["MyPISystemName"];

                    AFDatabase db = ps.Databases["Database1"];

                           AFTable tbl = db.Tables["Table1"];


                          // Get the timezone name, if any.

                          var timeZoneStr = tbl.GetExtendedProperty("ColumnName1", "TimeZone");


                          // Attempt to convert to an AFTimeZone object.

                    AFTimeZone timeZoneObj;

                          if (timeZoneStr is string)

                        timeZoneObj = AFTimeZone.FromName(timeZoneStr as string);


                          // Get the UOM name, if any.

                          var uomStr = tbl.GetExtendedProperty("ColumnName1", "UOM");


                          // Attempt to find the uom with that name;

                    UOM uomObj;

                          if (uomStr is string)

                       uomObj = ps.UOMDatabase.UOMs[uomStr as string];




            • Re: AF Table Column Definitions

              So using "UOM" as the property name did work for the GetExtendedProperty method. Though, it looks like you're calling it form a table object? I can only access it on an AFTable object. Might be a typo?


              My bigger question is, how are we to know the property in the UI is "Unit Of Meausure" is referenced as "UOM" somewhere else? I tried to get the "Value Type" as labeled in the UI by using the GetExtendedProperty method with "ValueType" as the property, and didn't have much luck with that as well, i had to get the Value type by getting the DataType property on the columns class. So, i'm not seeing consistency, and when trying to get these extended properties.