How to write a Perl hook in IBM Rational ClearQuest to change the state from Submitted to Assigned
How do you write a Perl hook in IBM Rational ClearQuest to change the state from Submitted to Assigned, if assignee field has some value at the time of record submission?
You would like to design your schema where a hook code should automatically change the state from Submitted to Assigned; if assignee field has some value at the time of record submission.
A Notification Perl hook code at action Submit can be written to achieve this requirement.
- Login to ClearQuest Designer with the role admin
- Click on Record Types > Navigate to the Record Type (For example Defect) > States And Actions > Actions > Submit
- Double click on Submit action, this will show all the Actions in right side panel
- Select the row of Submit action and click on the cell under the Notification column. It will open a drop down button, click on it and select SCRIPTS -> Add Perl Script
- This will Open the Notification Subroutine in Perl Script Editor
my($actionname, $actiontype) = @_;
# $actionname as string scalar
# $actiontype as long scalar
# action is Validate
# record type name is Defect
# Start User Code
# Post-commit notifications about actions may be handled here.
# End User Code
- Place the following code within this subroutine before # End User Code
$sessionObj = $entity->GetSession();
my $currstateobj = $entity->GetFieldValue("State");
my $currstate = $currstateobj->GetValue();
if ($currstate eq "Submitted")
my $assigneeobj = $entity->GetFieldValue("Assignee");
my $assignee = $assigneeobj->GetValue();
my $idobj = $entity->GetFieldValue("id");
my $id = $idobj->GetValue();
$entityToEdit = $sessionObj->LoadEntity("defect", $id);
$status = $entityToEdit->Validate();
if ($status == "")
- Save the work and perform Validation and check for errors
- If no errors, perform a Test Work
- Verify in the Test Database, if it is working as expected
- Once verified in the Test Database, CheckIn the Schema and Upgrade the Database
In the Above example we have made a few considerations:
- Hook code should move the state from Submitted to Assigned.
- There are NO Mandatory fields when moving from Submitted to Assigned State.
- Record type is Defect.
- Action name which changes the state from Submitted to Assigned is Assign.
Translate this page: