アクション検証フックは、一連の関連フィールド値が有効かどうかなど、フィールド レベルでの検証が困難な条件を確認します。フィールド レベルの検証フックは、フィールドが変更されると直ちに実行されます。一方、アクション検証フックは、ユーザーがレコードの編集を完了してデータベースへのコミット準備ができるまで実行されません。
次の例では、ユーザーが、指定のプロジェクトに対して正しいクライアント オペレーティング システム (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; }