0
Not a bug

No entities available in $sourceEntities, $targetEntities or $joinedEntities PowerShell incoming synchronization task during Changes Synchronization

Adrian Corston 5 years ago in UNIFYBroker/Plus updated by Beau Harrison (Senior Product Software Engineer) 5 years ago 3

I have two Pending Incoming Sync Changes for un-joined Adapter objects (i.e. no corresponding Locker objects), and I added the following logging to an Incoming Synchronisation Task in order to see what data is available for those objects.  In the log file it seems the task ran twice but there were *no* entities reported at all either time, for any of the $joinedEntities, $sourceEntities or $targetEntities objects.

$Logger.LogInformation("******** DET INCOMING SYNC ********")

foreach ($source in $sourceEntities)
{
    $Logger.LogInformation("Source Entity " + $source["detnumber"].Value)
}

foreach ($target in $targetEntities)
{
    $Logger.LogInformation("Target Entity " + $target["EmployeeID"].Value)
}

foreach ($entity in $joinedEntities)
{
    $Logger.LogInformation("Joined Entity " + $entity.SourceEntity["detnumber"].Value + "/" + $entity.TargetEntity["EmployeeID"].Value)
}

$Logger.LogInformation("********* DET INCOMING SYNC done *********")

Log file output:

Image 5302

Answer

Answer
Not a bug

Hi Adrian, those entity collections were empty in a sync task because there were no changes to be synchronized at that point. The new target entities were provisioned first since they did not exist. When normal synchronization ran after the provisioning stage, there were no remaining changes requiring action, so the entity collections provided to the sync task PS script were empty.

Answer
Not a bug

Hi Adrian, those entity collections were empty in a sync task because there were no changes to be synchronized at that point. The new target entities were provisioned first since they did not exist. When normal synchronization ran after the provisioning stage, there were no remaining changes requiring action, so the entity collections provided to the sync task PS script were empty.

Hi Beau,

Provisioning is not enabled on this Link, so those two objects never joined to a Locker.  It seems pointless (and wasteful, if the Task happens to perform any setup actions prior to processing $joinedEntities) to run the Task twice when there are no joined records that require processing at any time during a Changes Synchronization process.

For the purpose of debugging it would be very helpful to be able to query the source entities for the Pending Incoming Sync Changes, even if they aren't going to join to Lockers at this time.

This came about because Matt suggested I try this in order to see if the objects were exposed or not, while debugging an unrelated problem.

Sync tasks run on every appropriate sync, even empty ones, so the scripts should be written with this in mind. I'll make sure this point is made clear in the documentation.

I'll add a backlog item to look into making more information available to sync tasks scripts.