Is it possible to use old values in a script?

I would like to use $CustomProperty01[o]$ using Entities

Dim empQr = Query.From("Person").Where(String.Format("CentralAccount = '{0}'",cAcc)).SelectAll()
Dim empRes = Session.Source.GetCollection(Of Person)(empQr, EntityCollectionLoadType.Slim)

For Each emp As Person In empRes
     ' Value at the moment
     emp.CustomProperty01    
Next


Parents Reply Children
  • This would be my generic solution for an entity column's latest "old" value.

    Public Function CCC_PreviousColumnValue(ByVal xObjectKey As String, columnName As String, Optional backTo As Date = Nothing) As String
        If String.IsNullOrWhiteSpace(xObjectKey) Then
            Throw New ArgumentNullException(NameOf(xObjectKey))
        End If
        If String.IsNullOrWhiteSpace(columnName) Then
            Throw New ArgumentNullException(NameOf(xObjectKey))
        End If
    
        Dim source = Session.Resolve(Of History.IHistorySource)()
        Dim columns = New List(Of String) From {columnName}
    
        Dim previousColumnValue = source.GetChanges(New DbObjectKey(xObjectKey), columns, backTo, History.HistoryMode.WithFkDisplays).
            OrderByDescending(Function(x) x.ChangeTime).FirstOrDefault?.GetOldValue(columnName)
    
        Return previousColumnValue
    End Function