Problems filtering for dates in BG_USER_30 using Perl and Win32::OLE / OTA API (11679 Views)
Reply
Occasional Visitor
Skeeve
Posts: 2
Registered: ‎06-07-2013
Message 1 of 4 (11,679 Views)
Accepted Solution

Problems filtering for dates in BG_USER_30 using Perl and Win32::OLE / OTA API

Yes... A quite uncommon problem, isn't it?

 

I'm trying to use perl to access QC 10 and I got it running quite well I think,

 

But now I have a problem with dates in BG_USER_30 which is displayed in QC as "Modified".

 

I used the filter setting ">= 5/1/2013" and got 4 results. Then I used ">= 05/01/2013" and got 31 results.

 

It seems the value in that field is in fact a text and using OTA API isn't able to handle this.

 

An indicator for this is the results that I get. Example:

 

7283    21.05.2013 15:47:15     ("German" notation)
7733    17/05/2013 13:55:24    (DD/MM/YYYY hh:mm:ss)
8436    6/5/2013 2:58:10 PM     (M/D/YYYY h:mm:ss AMPM)
8555    2013-05-13                       (ISO Year)
8736    07/06/2013 12:01:05    (DD/MM/YYYY hh:mm:ss)

As you can see, it is a "nice" mixture.

 

Am I right in my assumption that BG_USER_30 is just a textfield and the display on QC's webinterface is simply somehow converted to display it properly? What could possibly be done to resolve that problem. Note: I'm just a user, not an admin of the server.

 

Just for completeness, here is my perl script, should anyone be interested.

Spoiler
#!/usr/bin/perl
use strict;
use Data::Dumper;
$Data::Dumper::Indent= 1;

my $MYSERVER= "https://.../qcbin";
my $USER= "...";
my $PASS= "...";
my $DOMAIN= "...";
my $PROJECT= "...";

# Return a connection with Test Director via the TD Object.
eval 'use Win32::OLE';
die "Unable to load Win32::OLE module: $@\n" if $@;
Win32::OLE->Option(_NewEnum => 1);
  
my $tdc = Win32::OLE->new('TDapiole80.TDconnection');
if (!$tdc) {
    die "Cannot start TestDirector object";
}

# Connect to specified server and project.
$tdc->InitConnectionEx($MYSERVER);
$tdc->Login($USER , $PASS);
$tdc->Connect($DOMAIN, $PROJECT);

my $BugFactory= $tdc->BugFactory();
my $Fields= $BugFactory->Fields->{_NewEnum};

my $BugFilter= $BugFactory->Filter;
$BugFilter->SetProperty('Filter', 'BG_USER_30', '>= 05/01/2013');
my $BugList = $BugFilter->NewList()->{_NewEnum};

foreach my $Bug (@$BugList) {
    print $Bug->ID(),"\t",$Bug->Field('BG_USER_30'),"\n";
}
print scalar @$BugList,"\n";

 

 

 

 

Honored Contributor
Trudy Claspill
Posts: 3,706
Registered: ‎09-09-2010
Message 2 of 4 (11,665 Views)

Re: Problems filtering for dates in BG_USER_30 using Perl and Win32::OLE / OTA API

The fact that the field name is "BG_USER_##" indicates it is a custom field rather than a built in field. Somebody with adminstrative access to the project can look at the project Customization information and tell you what Type of field it is.

It is also possible that custom code has been added to the workflow to modify the way the data is displayed. That is also something that somebody with administrative access to the project could tell you.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Honored Contributor
Jan Czajkowski
Posts: 2,112
Registered: ‎12-12-2007
Message 3 of 4 (11,649 Views)

Re: Problems filtering for dates in BG_USER_30 using Perl and Win32::OLE / OTA API

My guess is the field was defined as a String field and not as a Date field, and that the field is set from the workflow.

 

If you just assign the field for example by the VBScript Now function, you will get the date format according to the current regional settings of the client accessing the project. If the regional settings of the users vary, you will get a result like this.

 

You should ask the administrator to look into this, and probably have the field values normalized.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Occasional Visitor
Skeeve
Posts: 2
Registered: ‎06-07-2013
Message 4 of 4 (11,641 Views)

Re: Problems filtering for dates in BG_USER_30 using Perl and Win32::OLE / OTA API

You both are right.

I used the wrong field. The examples I looked at, when deciding which field is the correct one, suggested BG_USER_30. But this is really a string field and just had similar dates to the field I reallyhad to use, by coincidence.

Anyway: It was a "nice" experience trying to access QC using perl.

But I hope we will get QC11 and I can use the REST API and a proper operating system for making my queries ;)
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.