상위 레코드와 일치하도록 중복 레코드 업데이트

다음 코드 단편 예제는 레코드(엔티티)에 중복(하위)이 있는지 여부를 확인합니다. 중복이 있는 경우 후크는 각 중복을 dupone 조치 이름으로 편집하고, "action_info" 필드를 설정하여 원본(상위) 레코드가 테스트되었음을 표시합니다.

참고: 조치 알림 후크를 사용하여 중복 레코드를 원본 레코드와 동기화합니다. 조치 알림 후크는 레코드가 성공적으로 데이터베이스에 커미트된 후 실행됩니다. 조치 알림 후크 대신 조치 커미트 후크를 사용할 수 있습니다. 하지만 조치 커미트 후크를 사용하면 위험이 따릅니다. 상위 레코드가 데이터베이스로 커미트되지 않은 상태에서 하위 레코드가 데이터베이스에 커미트되면 레코드가 동기화되지 않습니다. 중첩 조치를 사용할 수도 있습니다. "조치 및 액세스 제어"중첩 조치를 참조하십시오.

VBScript

Dim status
Dim session    ' The current Session object
Dim parent_id    ' The current Entity's display name (ID string)
Dim dups  ' Array of all direct duplicates of this Entity
Dim dupvar    ' Variant containing a Link to a duplicate
Dim dupobj  ' The same Link, but as an Object rather than a Variant
Dim entity        ' The Entity extracted from the Link

If (HasDuplicates()) Then 
   Set session = GetSession 
   dups = GetDuplicates 
   parent_id = GetDisplayName 
   for each dupvar in dups 
      ' You could check these various functions for failures and 
      ' then report any failures to the user (for example, using
      ' MsgBox). 
      ' Failures are unlikely, but possible--for example, someone 
      ' could concurrently "unmark" an entity as a duplicate. 
      Set dupobj = dupvar 
      Set entity = dupobj.GetChildEntity 
      session.EditEntity entity, "dupdone" 
      SetFieldValue "action_info", _ 
            "Original " & parent_id & " is tested" 
      ' commit the record to the database if validation returns no
      ' errors

      status = entity.Validate 

     if status = "" then 

         entity.Commit 
      else

          entity.Revert  

       End If 
   Next
End If 

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 {

} 

피드백