조치 유효성 검증 후크는 관련 필드 값 세트의 유효성과 같은 필드 레벨에서 확인하기 어려운 조건을 검사합니다. 필드 레벨 유효성 검증 후크는 필드가 수정되면 즉시 실행됩니다. 조치 유효성 검증 후크는 사용자가 레코드 수정을 완료하고 이를 데이터베이스에 확약할 준비가 될 때까지 실행되지 않습니다.
다음 예제는 사용자가 주어진 프로젝트에 올바른 클라이언트 운영 체제(OS)를 입력했는지 확인합니다. 프로젝트에 지정된 운영 제체가 지원되지 않는 경우 이 후크는 유효성 검증 오류 메시지를 생성하여 리턴합니다.
Function defect_Validation(actionname, actiontype) ' actionname As String ' actiontype As Long ' defect_Validation As String ' action = teststate set sessionObj = GetSession ' Get the client OS platform the user indicated. platform = GetFieldValue("client_os").GetValue() ' Get the project name the user indicated. This information ' is stored on a referenced, stateless record. projectName = GetFieldValue("project.name").GetValue() ' Check the project name against the OS type. If the given project ' is not targeted for that platform, return a validation error. If projectName = "Gemini" Then If platform <> "NT" Then defect_Validation = "That project only supports NT." End If ElseIf projectName = "Aquarius" Then If platform <> "Unix" Then defect_Validation = "That project only supports Unix." End If End If End Function
sub defect_Validation { my($actionname, $actiontype) = @_; my $result; # $actionname as string scalar # $actiontype as long scalar # $result as string scalar # action = teststate # Returns a non-empty string explaining why the action # can not commit with the current values. # Or, if it is valid, returns an empty string value. my ($session, $platform, $projectRecordID, $projectRecord, $projectName, ); $session=$entity->GetSession(); # Get the client OS indicated by the user. $platform = $entity->GetFieldValue("client_os")->GetValue(); # Get the project name the user indicated. This information # is stored on a referenced, stateless record. $projectName = $entity->GetFieldValue("project.name")->GetValue(); # Check the project name against the OS type. If the # given project is not targeted for that platform, # return a validation error. if ($projectName eq "Gemini") { if ($platform != "NT") { $result = "That project only supports NT."; } } elsif ($projectName eq "Aquarius") { if ($platform != "Unix"){ $result = "That project only supports Unix."; } } return $result; }