Where are you doing this the webui? I’m using
configure-queue-script-new script-condition: on status change, action:
user defined.
In the preparation section I put
$RT::Logger->debug(“SCRIPT: $TicketObj->OwnerObj->Name\n”);
It should be $self->TicketObj
I then ran it again and got
SCRIPT:
RT::Action::UserDefined=HASH(0xcc9e670)->TicketObj->OwnerObj->Name()
The perldoc Ticket_Overlay has CustomFieldValues which sends you to
ObjectCustomFieldValues_Overlay which has
LimitToCustomField FIELD
Limits the returned set to values for the custom field with Id FIELD
LimitToTicket TICKETID
Limits the returned set to values for the ticket with Id TICKETID
Returns true if this CustomFieldValues collection has an entry with
content that eq VALUE
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; }