Sync: Revision value in Powershell Connector

I have a PS connector project and the source objects all have a lastchanged-field that I use for revision (IsRevision="true").
The requests are more or less slow (depending on the result size), but there's the possibility to filter by that field. So I wonder how to filter the data with the current revision stored inside the sync project.

To put it in simple words (SQL) - I want to:
SELECT *
FROM data
WHERE lastchanged > @revision
So my question is: how to get the current revision value (@revision) inside the PS command?
Is there a "special" parameter (like the modification parameters) or do I miss a Source type of the SetParameter-config?
  • Schema example:

    <Class Name="User">
        <Properties>
            </Property>
                <Property Name="WhenUpdated"  DataType="DateTime" IsRevision="true" AccessConstraint="ReadOnly">

    Posh example:

    <CustomCommand Name="Get-User">
    ....
    $response = Invoke-RestMethod -Method Get -Uri $url.ToString()
    Add-Member -InputObject $response -MemberType NoteProperty -Name 'WhenUpdated' -Value ([datetime]::Parse($response.lastChanged))
    $response

  • Thanks for the answer  . My question is not how to configure the revision propery (that part works), but how to use the last stored revision date in the query like

    <CustomCommand Name="Get-User">
    params(
        [Parameters()] [DateTime] $revisionDate # how to get the information here, so I can use it as a filter argument below
    )
    
    
    $response = Invoke-RestMethod -Method Get -Uri -Headers @{"lastupdated" = $revisionDate} $url.ToString()
    $response

    in order to prefilter the data from the source system.

  • You could get the "revisionDate" by a scripted variable.

    Dim revisionDate As String = args.QueryDatabase( _
                    Connection.SystemQuery _
                                   .From("DPRRevisionStore") _
                                   .Select("RevisionDate").Filter(UID_DPRRevisionStore='guid of the targetsystem/schematype entry' )) _
                    .Result.First.GetValue("RevisionDate").AsString
    Return revisionDate

    I'm still unsure if your plan is feasible, the sync engine has it's own matching logic and operations.
    But keep me informed!