How to find all the defects which are in "Opened" state and owned by a specific user using Rational ClearQuest APIs

Technote (FAQ)


Question

How do you find all the defects which are in the "Opened" state and owned by a specific user using IBM Rational ClearQuest APIs?

Cause

You need to get an instant and a brief report on the Opened state defects owned by a specific ClearQuest user without logging into IBM Rational ClearQuest Client.

Answer

The following Perl Script uses the ClearQuest API and can be run on Microsoft Windows.

Note: The ClearQuest Native Client must be installed on this machine.

This script iterates through all the ClearQuest Defects to find all the Opened state defects which are owned by a specific ClearQuest user. This script will print Record ID, Owner of the Record and Owner's Email to the command prompt.

Procedure:

  1. Navigate to the location where CQperl.exe is installed.

    By default: C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe

  2. Save the following Perl script text to notepad and save with a .pl extension.

    Note: In the below example you want to find all the Opened state defects owned by the user Engineer

    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.



    *******************************
    #!C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe
    # Make sure you have correct path for CQperl.exe

    use CQPerlExt;

    # Create a Rational ClearQuest admin session
    my $sessionObj = CQSession::Build();

    # Logon as admin
    # Provide correct values for admin password, User Database, and Schema Repository name

    $sessionObj->UserLogon("admin", "<adminPassword>", "<UserDatabase>", "<SchemaRepository>");

    my $userid = "engineer";

    my $sqlstring = "select distinct T1.dbid,T1.id,T8.login_name,T8.email from Defect T1,users T8,statedef T2 where T1.owner = T8.dbid and T1.state = T2.id and (T1.dbid <> 0 and ((T8.login_name = '$userid' and T2.name = 'Opened')))";

    my $ResultSet = $sessionObj-> BuildSQLQuery($sqlstring);

    $ResultSet->EnableRecordCount();
    $ResultSet->Execute();
    $recordCount = $ResultSet->GetRecordCount();

    print "Total number of "Opened" state defects owned by user - $recordCount\n";
    for ($i=0;$i<$recordCount;$i++) {
    $status = $ResultSet->MoveNext();

    $ClearQuestID[$i]= $ResultSet->GetColumnValue(2);
    $Owner[$i] = $ResultSet->GetColumnValue(3);
    $OwnerEmail[$i] = $ResultSet->GetColumnValue(4);

    print "ID-$ClearQuestID[$i]  *** Owner-$Owner[$i] *** Email-$OwnerEmail[$i]\n";
    }

    #Unbuild the Admin session
    CQPerlExt::CQSession_Unbuild($sessionObj);
    *******************************

  3. Run the script using the following command:

    cqperl <filename.pl>

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational ClearQuest
API

Software version:

7.1.2.9

Operating system(s):

Windows

Reference #:

1653058

Modified date:

2013-10-15

Translate my page

Machine Translation

Content navigation