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

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
jnarins@seniorbridge.com
seniorbridge.comhttp://www.seniorbridge.com/

[http://www.seniorbridge.com/images/seniorbridgedisclaimerTAG.gif]

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: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] 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

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…

I’d have a Scrip that set the Owner based on that CF and then have a
scrip that notifies Owners on owner change.

-kevin

That is exactly what I would like to have happen, but I am having a bit of a challenge finding the correct code snipits to accomplish this. I believe that I am pretty much looking at a big if/then statement. I am pretty much a novice at Perl but can figure things out if pushed in the right direction.

If I have a custom field called ‘Location’ and a user called ‘Bob’ with an e-mail of ‘bob@bob.com’, what is the beginning of a scrip that would test the Location and notify Bob if the Location matches, say, Oregon?

Do I need two scrips here? One to do the matching and set the owner, and another to do the notification?

Thanks for the help,

Kurt EngleFrom: “Kevin Falcone” falcone@bestpractical.com
To: rt-users@lists.bestpractical.com
Sent: Thursday, December 2, 2010 7:03:03 AM
Subject: Re: [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…

I’d have a Scrip that set the Owner based on that CF and then have a
scrip that notifies Owners on owner change.

-kevin

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 EngleFrom: “Josh Narins” jnarins@seniorbridge.com
To: “Kurt Engle” engle@4j.lane.edu, “rt-users” rt-users@lists.bestpractical.com
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
jnarins@seniorbridge.com

SeniorBridge

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: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] 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

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
LBNLOn Thu, Dec 2, 2010 at 8:00 AM, Kurt Engle engle@4j.lane.edu 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” jnarins@seniorbridge.com
*To: *“Kurt Engle” engle@4j.lane.edu, “rt-users” <
rt-users@lists.bestpractical.com>
*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
jnarins@seniorbridge.com
seniorbridge.com http://www.seniorbridge.com/

[image: SeniorBridge]


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: rt-users-bounces@lists.bestpractical.com [mailto:
rt-users-bounces@lists.bestpractical.com] *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

Kurt,

Sorry, I forgot to change this line:

my $cfvalue = $ticket->FirstCustomFieldValue(‘CF Name’);

Kenn
LBNLOn Thu, Dec 2, 2010 at 9:25 AM, Kenneth Crocker kfcrocker@lbl.gov 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 engle@4j.lane.edu 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” jnarins@seniorbridge.com
*To: *“Kurt Engle” engle@4j.lane.edu, “rt-users” <
rt-users@lists.bestpractical.com>
*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
jnarins@seniorbridge.com
seniorbridge.com http://www.seniorbridge.com/

[image: SeniorBridge]


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: rt-users-bounces@lists.bestpractical.com [mailto:
rt-users-bounces@lists.bestpractical.com] *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

Ken, thanks for the code. I will give it a go and see what happens. One question. I am not wanting to set the owner of the ticket, but simply send out a notification to a specific person based on the CF value. The owner of the ticket will be set in the usual manner of 'take’ing the ticket.

Does that change this process?

Kurt EngleFrom: “Kenneth Crocker” kfcrocker@lbl.gov
To: rt-users@lists.bestpractical.com
Sent: Thursday, December 2, 2010 9:25:25 AM
Subject: Re: [rt-users] Notify based on CF

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

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 SchoolsFrom: “Kenneth Crocker” kfcrocker@lbl.gov
To: rt-users@lists.bestpractical.com
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

You declare “my %org” but then use the variable as %orgs with “= $orgs{$cfvalue}”

The extra s is the problem.From: Kurt Engle [mailto:engle@4j.lane.edu]
Sent: Wednesday, December 08, 2010 06:20 PM
To: Kenneth Crocker kfcrocker@lbl.gov
Cc: rt-users@lists.bestpractical.com rt-users@lists.bestpractical.com
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” kfcrocker@lbl.gov
To: rt-users@lists.bestpractical.com
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