Updating duplicate records to match the parent record
The following code fragment example checks to see whether the record (entity) has any duplicates (children). If so, the hook edits each of the duplicates with the dupone action name, and sets the "action_info" field to indicate that the original (parent) record is tested.
Note: You synchronize duplicate records with the original
record by using an action notification hook. An action notification
hook fires after a record has been successfully committed to the database.
You can use an action commit hook instead of an action notification
hook. However, using an action commit hook creates a risk: if the parent record
is not committed to the database, but the children records are committed
to the database, your records will be out of synch. You can also use nested
actions. See "Actions and access control" and Nested actions.
Perl
my($session); # The current Session object
my($links); # The reference to the links collection object
my($link);
my($cnt);
my($itm);
my($childID);
if ($entity->HasDuplicates()) {
$session = $entity->GetSession();
$links = $entity->GetDuplicates();
$session->OutputDebugString("links is " . $links . "(" . ref ($links) .
")\n" );
$cnt = $links->Count();
$session->OutputDebugString("count is " . $cnt . "(" . ref ($cnt) .
")\nchildren:\n" );
for ($i = 0; $i<$cnt; $i++) {
$itm = $links->Item($i);
$session->OutputDebugString("Item is " . $itm . "(" . ref ($itm) . ")\n";
$childID = $itm->GetChildEntityId();
$session->OutputDebugString($childID . "\n" );
}
$session->OutputDebugString("done");
}
else {
}