Lookup of Requestor Custom Field

I have a request to create a scrip that will automatically assign an owner to a ticket based on the requestor’s assigned Purchaser.

I have a Global custom field Purchaser, assigned to all Users.
Select one value.
For each value, Name is the username of the Purchaser, and Description is their full name (to make things easy for the managers).

So far my attempts to get the value of the custom field have ended in failure, mostly with
[error]: Impossible to assign the ticket to : That user does not exist ((eval 1502):10)

My current script is below. Am I missing something obvious here? I’ve been up and down the PODs and I’m not finding a fix for this.

PREP
return 1;

CLEANUP:
#Get requestor
my $Reqstr_Obj = $self->TicketObj->Requestors;

get value of custom field, which should be user ID of newowner

my $newowner = $self->TransactionObj->CreatorObj->_Value(‘Purchaser’);
$RT::Logger->error( $newowner );

#set the owner
my ($status, $msg) = $self->TicketObj->SetOwner( $newowner );
unless( $status ) {
$RT::Logger->error( “Impossible to assign the ticket to $newowner: $msg” );
return undef;
}
return 1;

Jourdan Perla
BFTV Admin Group (BAE/FST/TEX/VEN)
University of California, Davis
530-752-3065

You need FirstCustomFieldValue method instead of _Value.

Ruslan from phone.25.04.2012 1:59 пользователь “Jourdan Perla” jkperla@ucdavis.edu написал:

I have a request to create a scrip that will automatically assign an
owner to a ticket based on the requestor’s assigned Purchaser.****


I have a Global custom field Purchaser, assigned to all Users.****

Select one value.****

For each value, Name is the username of the Purchaser, and Description is
their full name (to make things easy for the managers).****


So far my attempts to get the value of the custom field have ended in
failure, mostly with ****

[error]: Impossible to assign the ticket to : That user does not exist
((eval 1502):10)****


My current script is below. Am I missing something obvious here? I’ve been
up and down the PODs and I’m not finding a fix for this.****


PREP****

return 1;****



CLEANUP:****

#Get requestor****

my $Reqstr_Obj = $self->TicketObj->Requestors;****

get value of custom field, which should be user ID of newowner****

my $newowner = $self->TransactionObj->CreatorObj->_Value(‘Purchaser’);****

$RT::Logger->error( $newowner );****


#set the owner****

my ($status, $msg) = $self->TicketObj->SetOwner( $newowner );****

unless( $status ) {****

$RT::Logger->error( "Impossible to assign the ticket to $newowner:

$msg" );****

return undef;****

}****

return 1;****


-----****

Jourdan Perla****

BFTV Admin Group (BAE/FST/TEX/VEN)****

University of California, Davis****

530-752-3065****


That did it. Thanks!From: Ruslan Zakirov [mailto:ruslan.zakirov@gmail.com]
Sent: Tuesday, April 24, 2012 10:23 PM
To: Jourdan Perla
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Lookup of Requestor Custom Field

You need FirstCustomFieldValue method instead of _Value.

Ruslan from phone.