You declare "my %org" but then use the variable as %orgs with "=
$orgs{$cfvalue}"
The extra s is the problem.
From: Kurt Engle [mailto:[email protected]]
Sent: Wednesday, December 08, 2010 06:20 PM
To: Kenneth Crocker <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [rt-users] Notify based on CF
Ken... I pretty much have this working but I am getting an error in the code of
the scrip that you sent me. Here is the scrip as I ahve it on my system:
----
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $ownerid = 10; # Nobody
my %org = qw(
ComputerandInformationSvs 34
SEHS 34
);
my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "Building");
return 0 unless $cf->id;
my $cfvalue = $ticket->FirstCustomFieldValue('Building');
$cfvalue =~ s/\s+//g;
my $ownerid = $orgs{$cfvalue};
# set new Ticket Owner ID
$ticket->SetOwner($ownerid);
return 1;
-----
I am getting this error when it runs:
Scrip 24 Prepare failed: Global symbol "%orgs" requires explicit package name
at (eval 6318) line 16. (/opt/rt3/bin/../lib/RT/Action/UserDefined.pm:64)
If I remove the 'my $ownerid = $orgs{$cfvalue};' line the error goes away and,
of course, the last line does not work.
Kurt Engle
Network Engineer
Eugene 4J Schools
________________________________
From: "Kenneth Crocker" <[email protected]>
To: [email protected]
Sent: Thursday, December 2, 2010 9:26:59 AM
Subject: Re: [rt-users] Notify based on CF
Kurt,
Sorry, I forgot to change this line:
my $cfvalue = $ticket->FirstCustomFieldValue('CF Name');
Kenn
LBNL
On Thu, Dec 2, 2010 at 9:25 AM, Kenneth Crocker
<[email protected]<mailto:[email protected]>> wrote:
Kurt,
I agree with Kevin. The following is a simple scrip that sets the Owner based
on the value in a Custom Field array:
Name: Set owner on CF
Condition:On Create
Action:User-defined
Template: Blank
Stage: TransactionCreate or TransactionBatch
Custom Action Prep:
# ------------------------------------------------------------------- #
# Set ticket owner based on Custom Field
# KFCrocker 6/01/09
# ------------------------------------------------------------------- #
# set new ticket owner id value
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $ownerid = 10; # Nobody
my %orgs = qw(
value1 999
value2 999
value3 999
);
my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "CF Name");
return 0 unless $cf->id;
my $cfvalue = $ticket->FirstCustomFieldValue('CFO-Org');
my $ownerid = $orgs{$cfvalue};
# set new Ticket Owner ID
$ticket->SetOwner($ownerid);
return 1;
Custom Action Cleanup:
return 1;
Then follow up by creating a separate notification on Owner change.
Hope this helps.
Kenn
LBNL
On Thu, Dec 2, 2010 at 8:00 AM, Kurt Engle
<[email protected]<mailto:[email protected]>> wrote:
I have RT::Extension::ExtractCustomFieldValues installed and working. I do not
have a problem populating the CF of a ticket. What I do need is a way to test
that value and then notify an e-mail address based on the CF value.
Basically, I need some help with Perl to accomplish this...
Kurt Engle
________________________________
From: "Josh Narins" <[email protected]<mailto:[email protected]>>
To: "Kurt Engle" <[email protected]<mailto:[email protected]>>, "rt-users"
<[email protected]<mailto:[email protected]>>
Sent: Thursday, December 2, 2010 6:26:56 AM
Subject: RE: [rt-users] Notify based on CF
Do you want a partial solution, to get started?
I installed RT::Extension::ExtractCustomFieldValues and I think your first step
would be to add a Scrip for "On Create" with action "Extract Custom Field
Values" but exactly what you'd need to do then eludes me. Something like
"Create a template where the To: line is based on the value in the Custom Field"
But I'm still pretty new at all this RT stuff.
Josh Narins
Director of Application Development
SeniorBridge
845 Third Ave
7th Floor
New York, NY 10022
Tel: (212) 994-6194
Fax: (212) 994-4260
Mobile: (917) 488-6248
[email protected]<mailto:[email protected]>
seniorbridge.com<http://www.seniorbridge.com/>
________________________________
SeniorBridge Statement of Confidentiality: The contents of this email message
are intended for the exclusive use of the addressee(s) and may contain
confidential or privileged information. Any dissemination, distribution or
copying of this email by an unintended or mistaken recipient is strictly
prohibited. In said event, kindly reply to the sender and destroy all entries
of this message and any attachments from your system. Thank you.
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
On Behalf Of Kurt Engle
Sent: Wednesday, December 01, 2010 7:05 PM
To: rt-users
Subject: [rt-users] Notify based on CF
I am interested in setting up a notification tree based on a Custom Field
value. Basically, I have one Q that accepts tickets from multiple physical
locations. I have a tech at each location. I would like the tech at location X
to be notified when a ticket comes in with the Custom Field Location=X . When
the CF Location=Y, I want a different tech notified, etc...
Thanks for any help..
Kurt Engle