조치 초기화 후크 예제

초기화 후크는 조치 시작 시 복잡한 초기화를 수행합니다. 예를 들어, 이 후크를 사용하여 필드를 재설정하거나 조치의 유형을 기반으로 필드에 다른 값을 지정할 수 있습니다.

다음 코드는 사용자가 다른 사용자에게 결함을 재지정하는 경우 실행되는 후크입니다. 후크는 재지정 조치 시작 시 action_reason 필드의 컨텐츠를 지웁니다. 이 필드의 동작이 Mandatory로 설정된 경우 사용자는 결함을 재지정하는 이유를 제공해야 합니다.

VBScript

Sub swbug_Initialization(actionname, actiontype)

    ' actionname As String

    ' actiontype As Long

    ' action = reassign

    ' Empty the string at the beginning of the action

    SetFieldValue "action_reason", ""

End Sub 

Perl

sub swsub_Initialization {

    my($actionname, $actiontype) = @_;

    # $actionname as string scalar

    # $actiontype as long scalar

    # action is reassign

    # do any setup for the action here

    # Empty the string at the beginning of the action

    $entity->SetFieldValue("action_reason", "");

} 
참고: 스키마에서 사용자에게 각 조치를 수행하는 이유를 제공하도록 요구하면 DEFAULT_VALUE 후크를 사용하여 각 조치시작 시 action_reason 필드를 지울 수 있습니다. 이전 예제에서 필드 지우기는 재지정 조치에만 필요하므로 조치 초기화 후크가 사용하기에 더 적합한 후크입니다.

피드백