PowerShell Connector Import Changes Operation


As opposed to the Import All operation which gets all entities in the target system, the import changes operation only returns the entities that have changed. This operation is used to tell UNIFYBroker which entities have been Added, Updated and Deleted. There are two different types of import operations available.

Entity Changes

The first import changes method is the Entity Changes method, which only returns the entities that have changed. The syntax for this operation is exactly the same as the Import All operation, except that you can also use the Delete method to indicate entities which have been deleted. For example,

$changedEntity = $entities.Create();
$changedEntity['ID'] = 10002;
$changedEntity['...'] #etc.
$changedEntity.Commit(); # add or update this entity
$changedEntity = $entities.Create();
$changedEntity['ID'] = 10003; # only need to set key fields
$changedEntity.Delete(); # delete this entity

Entity ID Changes

Unlike the entity changes operation, the entity ID changes method supports all three types of changes (Adds, Updates and Deletes). This is achieved through a two step process.

Step 1 - List the changed entities

The first operation returns a list of all the keys of entities that have changed (Added / Updated and Deleted). The syntax for this operation is similar to the Import All operation, but instead of returning entities you return keys.

$changedKey = $keys.Create();
$changedKey['ID'] = 10002;

Step 2 - Retrieve entities for the keys

The second operations returns all entities that are listed in the collection of changed keys.

foreach ($key in $components.InputKeys)
     $changedEntity = $entities.Create();
     $changedEntity['ID'] = $key['ID'];
     $changedEntity['EmailAddress'] = 'NewEmail@address.com';

The result of this operations is the following:

  • When an entity hasn't been seen before it is considered an add.
  • When a key is listed, but no corresponding entity is returned, it is considered a delete (key changed, but no entity).
  • When the key is changed, and the entity has been seen before it is considered an update.

This article was helpful for 1 person. Is this article helpful for you?