![](/s/cache/21/92/2192bdaa5cc1ed11af11f2653ef995b5.png)
Access to source entity fields for target entities returned by CheckFieldUniqueness
When using the CheckFieldUniqueness component to ensure target entity field uniqueness I would like to use source entity field values in order to calculate candidate values for the unique field. I'm only aware of a way to access target entity field values.
Is there a way to access the source entities for a target entity in this scenario?
Otherwise, please change this ticket to an Idea to have the ability to do so.
Answer
![](/s/cache/e7/26/e7264cf61fd1989c92688c5c38d7beaa.png)
Hi Adrian
See Entity Components, in particular the Source Entities and Joined Entities sections. Also see PowerShell Task, which has an example of using the joinedEntities collection.
![](/s/cache/21/92/2192bdaa5cc1ed11af11f2653ef995b5.png)
Hi Beau,
The examples on those pages only refer to passing $targetEntities to CheckFieldUniqueness(). From a target entity, is it possible to get to source entity fields of the target entity for which a unique field value is to be calculated?
I want to be able to use source entity fields to generate a unique value in the target entity.
![](/s/cache/e7/26/e7264cf61fd1989c92688c5c38d7beaa.png)
I see. You could just mapping the required values to to fields on the target entities, but assuming you don't want to do that you should process the $joinedEntities
collection into a HashTable
keyed on the target entities. For example:
$entityMap = @{}; foreach ($joinedEntity in $joinedEntities) { $entityMap[$joinedEntity.TargetEntity] = $joinedEntity.SourceEntity; }
You'll then be able to use the target entities returned by CheckFieldUniqueness
to lookup the corresponding source entity efficiently.
Customer support service by UserEcho
I see. You could just mapping the required values to to fields on the target entities, but assuming you don't want to do that you should process the
$joinedEntities
collection into aHashTable
keyed on the target entities. For example:You'll then be able to use the target entities returned by
CheckFieldUniqueness
to lookup the corresponding source entity efficiently.