Topic
  • 9 replies
  • Latest Post - ‏2014-03-26T15:28:40Z by JackMcRoberts
JackMcRoberts
JackMcRoberts
7 Posts

Pinned topic Cannot access user data from hooks

‏2014-03-21T19:30:35Z |

I am having problems accessing the "users" database from within our schema. We maintain two repositories: a test one and a development one using an Oracle database. Both are running the same schema revision (no changes to the test one since the last upgrade).  The production repository operates properly.  On the development side, we have suddenly developed problems accessing the user database from hook code.  The code in question looks like:

    my $deliv_field_subcontractor = "Subcontractor" ;

    my $subcontractor_record_type = "MPM_CM_Subcontractor" ;

    my $subc_field_SCA_login = "SCA_login" ;

    my $deliv_field_SCA_login = "Approver_Login" ;

    my $deliv_field_SCA_fullname = "Approver" ;

    my $subc = $entity->GetFieldStringValue( $deliv_field_subcontractor ) ;

    my $subc_entity = $entity->GetSession()->GetEntity( $subcontractor_record_type, "$subc" ) ;

    my $SCA_login = $subc_entity->GetFieldStringValue( $subc_field_SCA_login ) ;

    $entity->SetFieldValue( $deliv_field_SCA_login, $SCA_login ) ;

    my $SCA_user_entity = $entity->GetSession()->GetEntity( 'users', '' . $SCA_login ) ;

When the highlighted line is executed, I get an error message (see attached screen shot) that there is no record of type "users" with the given name.

I have verified that the name is present in the database.  I have tried different user names in the source record that are in the user database.  I have used my own login name.  I have created a new login and have used that user.  I always get the same response.  I then tried to replace the access to "users" by using the BuildQuery approach but BuildQuery returns an undefined value. I have had other users try this (same result) and have tried the Windows, Eclipse and web clients with the same results.

  • DonaldN
    DonaldN
    287 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-23T23:07:20Z  

    Have you done ClearQuest diagnostic tracing yourself? If you can get hold of such a diagnostic file, it is quite easy to tell why ClearQuest reports such an error. If you don't know how to do it or how to read the file, contact IBM Rational Support.

    You basically follow the instructions in the below web page. For the "Trace" flags, you need "DB_CONNECT" to verify which database you connect to, "API" and "PERL" to help you step through the hook code, and "SQL" to see the exact SQL statement sent to the database. Once you get the SQL statement, you can run it (in SQL*Plus) against the Oracle database (which is identified by the "DB_CONNECT" flag) to verify whether the returned result set is correct.

    http://www-01.ibm.com/support/docview.wss?uid=swg21231445

    Edit to add: although you said the problem developed "suddenly", have you tried the "proper" API to get a user object? The way you did it is a bit strange. You do need an AdminSession to get the user object, comparing to what you already have.

    http://pic.dhe.ibm.com/infocenter/cqhelp/v7r1m2/topic/com.ibm.rational.clearquest.apiref.doc/topics/r_adminsession_getuser.htm

  • CQAdmin
    CQAdmin
    103 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-25T09:00:09Z  

    Please explain your exact requirement.

    You want to get the User's name in some drop-down field?

    http://www-01.ibm.com/support/docview.wss?uid=swg21641301

    Or you want have some kind of check like this-

    http://www-01.ibm.com/support/docview.wss?uid=swg21641287

    Considering the error message you have posted; that particular reference has to be deleted from the database.

     

     

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-25T20:36:33Z  
    • DonaldN
    • ‏2014-03-23T23:07:20Z

    Have you done ClearQuest diagnostic tracing yourself? If you can get hold of such a diagnostic file, it is quite easy to tell why ClearQuest reports such an error. If you don't know how to do it or how to read the file, contact IBM Rational Support.

    You basically follow the instructions in the below web page. For the "Trace" flags, you need "DB_CONNECT" to verify which database you connect to, "API" and "PERL" to help you step through the hook code, and "SQL" to see the exact SQL statement sent to the database. Once you get the SQL statement, you can run it (in SQL*Plus) against the Oracle database (which is identified by the "DB_CONNECT" flag) to verify whether the returned result set is correct.

    http://www-01.ibm.com/support/docview.wss?uid=swg21231445

    Edit to add: although you said the problem developed "suddenly", have you tried the "proper" API to get a user object? The way you did it is a bit strange. You do need an AdminSession to get the user object, comparing to what you already have.

    http://pic.dhe.ibm.com/infocenter/cqhelp/v7r1m2/topic/com.ibm.rational.clearquest.apiref.doc/topics/r_adminsession_getuser.htm

    The problem does not appear to be related to emails at all.  It looks like the "users" records in the database I am using are getting deleted somehow.  The master appears to be all right since I can log into CQ with no problem. However, if I attempt to dump all records of type "users", I get a list of them but, when attempting to access them, I get an error message that it cannot find the record; the dbid field at the bottom of the details screen is blank.  I cloned off my schema for testing purposes, built a new database, and exported some of the more basic records from the original database.  The user table in the new database is fine up to a point.   I find that if I try to import to many records(or maybe records with something odd about them), the user table in the database gets clobbered again.  Since this is a test database, I was able to prune down the number of records of enough types and get it to a point were I could try some real experiments with the schema.  I created a record, advanced it through a couple of state and... there went the user database again. So either there is something flaky about some script I am using wrt the record type  (which is probably the case) or there is something else fundamentally wrong with our installation. Which brings up the following questions: 1) what can clobber the users table in the schema database, and 2) is there anyway to restore it short of deleting and recreating the database?

  • DonaldN
    DonaldN
    287 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-25T23:00:51Z  

    The problem does not appear to be related to emails at all.  It looks like the "users" records in the database I am using are getting deleted somehow.  The master appears to be all right since I can log into CQ with no problem. However, if I attempt to dump all records of type "users", I get a list of them but, when attempting to access them, I get an error message that it cannot find the record; the dbid field at the bottom of the details screen is blank.  I cloned off my schema for testing purposes, built a new database, and exported some of the more basic records from the original database.  The user table in the new database is fine up to a point.   I find that if I try to import to many records(or maybe records with something odd about them), the user table in the database gets clobbered again.  Since this is a test database, I was able to prune down the number of records of enough types and get it to a point were I could try some real experiments with the schema.  I created a record, advanced it through a couple of state and... there went the user database again. So either there is something flaky about some script I am using wrt the record type  (which is probably the case) or there is something else fundamentally wrong with our installation. Which brings up the following questions: 1) what can clobber the users table in the schema database, and 2) is there anyway to restore it short of deleting and recreating the database?

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-26T14:43:23Z  
    • DonaldN
    • ‏2014-03-25T23:00:51Z

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

    That does explain things.  I appreciate the information.  Now I just have to find out how I am clobbering the "local" copy.

    Thanks for the responses.

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-26T14:43:58Z  
    • DonaldN
    • ‏2014-03-25T23:00:51Z

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

    That does explain things.  I appreciate the information.  Now I just have to find out how I am clobbering the "local" copy.

    Thanks for the responses.

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-26T14:48:00Z  
    • DonaldN
    • ‏2014-03-25T23:00:51Z

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

    That does explain things.  I appreciate the information.  Now I just have to find out how I am clobbering the "local" copy.

    Thanks for the responses.

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-26T15:07:56Z  
    • DonaldN
    • ‏2014-03-25T23:00:51Z

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

    That does explain things.  I appreciate the information.  Now I just have to find out how I am clobbering the "local" copy.

    Thanks for the responses.

  • JackMcRoberts
    JackMcRoberts
    7 Posts

    Re: Cannot access user data from hooks

    ‏2014-03-26T15:28:40Z  
    • DonaldN
    • ‏2014-03-25T23:00:51Z

    The only proper way to manipulate the "users" table from a GUI is the ClearQuest User Maintenance Tool, by subscribe/unsubscribe a user to a user database, then "upgrade" the user database. Basically, when a user is subscribed to user database, its record will be added to the user database. When unsubscribed, it will be removed.

    The schema repository (master) always has the full list of users, while each user database may only have a subset of the list.

    Using API to manipulate the "users" table should follow the same principle.

    That does explain things.  I appreciate the information.  Now I just have to find out how I am clobbering the "local" copy.

    Thanks for the responses.