Question & Answer
Question
How do you write a Perl hook code in IBM Rational ClearQuest to not allow a user (who is currently logged in) to modify a record if you are not the "Submitter" or "Assignee" or "Owner" of that particular record?
Cause
You would not want a user who has no role for a particular record or does not have permissions to modify that record to have any control on the record modifications.
Answer
Procedure:
- Login to IBM Rational ClearQuest Designer.
- CheckOut the Schema
- Click on Record Types - Go to Record - States and Actions - Actions
- Click on Modify action.
Under the Validation Column (row should be "modify"), select Perl as your script and write the below
Note - The Record Type is Defect in this case.
Hook code-
sub Defect_Validation {
my($actionname, $actiontype) = @_;
my $result;
$CQSession = $entity->GetSession();
$username = $CQSession->GetUserLoginName();
$SubmitterName = $entity->GetFieldValue("Submitter")->GetValue();
$OwnerName = $entity->GetFieldValue("Owner")->GetValue();
$AssigneeName = $entity->GetFieldValue("Assignee")->GetValue();
if ($SubmitterName ne $username && $OwnerName ne $username && $AssigneeName ne $username)
{
$result = "Modification not allowed for this record. This record does not belong to you.";
}
return $result;
}
- Save the work.
- Perform "Validation" and check if you see any errors. If no errors, perform a "Test Work"
- Verify in the Test Database, if it is working as expected.
- Once verified in the Test DB, checkin the Schema and Upgrade the "Database".
Disclaimer All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
[{"Product":{"code":"SSSH5A","label":"Rational ClearQuest"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Designer - Hooks","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.1.2;7.1.2.3;7.1.2.5;7.1.2.6","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]
Was this topic helpful?
Document Information
Modified date:
21 March 2021
UID
swg21641287