How do I get the column name from a DeltaChange (NewValues row)

I have a DeltaChange object where I need to process all values in the NewValues row.
I need to identify the column name for each index.
How do I obtain this column name?
I am now using Delta.Schema.Fields but this list has more entries if not all fields in the schema has LogChanges.
Is it safe to make a list by taking the LogChange=True fields? Is there a better approach?

Hi,

You can use something like:

var list := e.Delta.Schema.Fields.Where(f-> 
    f.LogChanges or f.InPrimaryKey or f.ServerAutoRefresh).ToList;

We use similar checking in GetFieldIndexInValueArray:

method Delta.GetFieldIndexInValueArray(fieldName: String): Int32;
begin
  var lResult: Int32 := -1;

  for each field: SchemaField in self.Schema.Fields do begin
    var lMatch: Boolean := String.Equals(fieldName, field.Name, StringComparison.OrdinalIgnoreCase);
    var lInArray: Boolean := field.LogChanges or field.InPrimaryKey or field.ServerAutoRefresh;

    if (lMatch and (not lInArray)) then
      break;

    if lInArray then begin
      inc(lResult);
      if (lMatch) then
        exit lResult;
    end
  end;

  exit -1;
end;

1 Like

Thanks for the info: I created something similar with only f.LogChanges but my code needs to be an exact match.
Some kind of API interface is probably more future proof