[rt-users] getting the values of custom fields

anthony acqant at optonline.net
Wed Feb 14 12:03:05 EST 2007


Joop,
	Thanks that really helps.  I'm able to pull the first value from my
custom field now.

	However the field I have is a multi value on and I'm not trying to use
CustomFiledValues which returns a ObjectCustomFieldValues Object.

I don't really know what to do with that.  I've tried a whole bunch of
things but I'm just guessing.

The ObjectCustomFiled Object has this as a Hash


[Wed Feb 14 16:55:32 2007] [debug]: _open_parens - HASH(0xa414aec)
((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: alias_count - 0 ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: where_clause -  ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: order_by - ARRAY(0xa523034) ((eval
948):50)
[Wed Feb 14 16:55:32 2007] [debug]: table - ObjectCustomFieldValues
((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: tables -  ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: is_limited - 1 ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: order -  ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: user -
RT::CurrentUser=HASH(0xa5f17c8) ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: limit_clause -  ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: DBIxHandle -
RT::Handle=HASH(0x9a42c6c) ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: restrictions - HASH(0xa61436c)
((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: primary_key - id ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: auxillary_tables -  ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: must_redo_search - 1 ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: itemscount - 0 ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: show_rows - 0 ((eval 948):50)
[Wed Feb 14 16:55:32 2007] [debug]: aliases - ARRAY(0xa42ceb4) ((eval
948):50)
[Wed Feb 14 16:55:32 2007] [debug]: first_row - 0 ((eval 948):50)



Thanks.



Joop wrote:
> anthony wrote:
>> I'm doing this via script action.
>> FirstCustom.. is in Record which is not part of the $self.
>>
>> I get TicketObj, TransactionObj ( which does not seems to work )
>>
>> I'm tried to use CustomFieldValues but I get stuck after that.
>>
>> Searches through the archive seem to say NO ONE has done this
>> successfully.
> This is part of our script which ties timeworked to an asset which hold
> how many hours a client has left on his contract.
> use Data::Dumper;
> 
> # start to define a couple of useful objects.
> my $TicketObj = $self->TicketObj;
> my $QueueObj  = $self->TicketObj->QueueObj;
> my $TransObj  = $self->TransactionObj;
> my $TemplObj  = $self->TemplateObj;
> # $RT::Logger->debug( Dumper($TemplObj) );
> my $qname     = $self->TicketObj->QueueObj->Name;
> my $cfname    = 'Strippenkaart';
> my $timetaken;
> my $abstimetaken_new;
> my $abstimetaken_old;
> my $assettype;
> 
> # $RT::Logger->debug("$qname");
> # $RT::Logger->debug("$timetaken");
> my $ttype  = $TransObj->Type;
> my $tfield = $TransObj->Field;
> # $RT::Logger->debug($ttype);
> # $RT::Logger->debug($tfield);
> 
> # make a new CFObj and fill it
> my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
> $CFObj->LoadByNameAndQueue( Name => $cfname, Queue => $QueueObj->id );
> unless ( $CFObj->id ) {
>     $CFObj->LoadByNameAndQueue( Name => $cfname, Queue => 0 );
>     unless ( $CFObj->id ) {
>         $RT::Logger->debug(
>                     "custom field '$cfname' isn't global or defined for
> queue '"
>                       . $QueueObj->Name
>                       . "'" );
>         return undef;
>     }
> }
> 
> # get the first CFValue
> my $cfvalue = $self->TicketObj->FirstCustomFieldValue( $CFObj->id );
> $RT::Logger->debug("$cfvalue");
> 
> # then create an empty AssetObj with the current user
> my $AssetObj = RTx::AssetTracker::Asset->new( $QueueObj->CurrentUser );
> 
> # get its values given the convention  AssetName=QueueName+CFValue
> # check if status == production
> # further Name is unique in the DB, is possible to change via
> AT_SiteConfig.pm
> # still check if  AssetType==Strippenkaart
> $AssetObj->Load($qname.$cfvalue);
> $assettype=$AssetObj->TypeObj->Name;
> if ( $assettype ne 'Strippenkaart' ) {
>     $RT::Logger->debug("No Asset of type Strippenkaart");
>     return undef;
> }
> 
> my $desc   = $AssetObj->Description;
> my $status = $AssetObj->Status;
> if ( $status ne 'production' ) { return undef; }
> 
> # $RT::Logger->debug("$desc");
> 
> # get the CustomFields  (cnt>0)
> my $AssetCFObj = $AssetObj->CustomFields();
> my $cfcount = $AssetCFObj->Count;
> if ( $cfcount == 0 ) { return undef; }
> 
> # process the CF's
> 
> 
> Does this make sense?
> 
> Joop
> 
> 
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy
> a copy at http://rtbook.bestpractical.com
> 




More information about the rt-users mailing list