IBM Support

Perl hook code should not allow a user to modify a record if user does not belong to that particular record.

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:

  1. Login to IBM Rational ClearQuest Designer.

  2. CheckOut the Schema

  3. Click on Record Types - Go to Record - States and Actions - Actions

  4. 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;

    }


  5. Save the work.

  6. Perform "Validation" and check if you see any errors. If no errors, perform a "Test Work"

  7. Verify in the Test Database, if it is working as expected.

  8. 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":"BU004","label":"Hybrid Cloud"},"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":""}]

Document Information

Modified date:
16 June 2018

UID

swg21641287