Using custom field that applies to group as custom scrip condition

We’re trying to base our autoreply on the value of a custom field that
applies to a group. So I’ve created a scrip that applies to a queue:

Condition: User Defined
Action: Autoreply To Requestors
Template: Global template: Contract Expiring
Stage: TransactionCreate

In the Custom condition this should only trigger when the custom field
"Contract Status" equals “expiring”:

if ( $self->TransactionObj->Type eq “Create” &&
$self->TicketObj->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring" )
return 1;
} else {
return 0;
}

I’ve also tried:

$self->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring"

But this code doesn’t trigger the template and I can’t seem to find a
similar example of the use of custom group fields anywhere.

Thanks,

~paul

Paul_Vlaar@isc.org - ISC Operations - PGP 0x294EC062

Paul,

I use the following scrip for the condition and it works for me:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’)
{my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,
Name => “Review Process”);
return 0 unless $cf->id;
if ($trans->Field == $cf->id &&
$trans->NewValue eq “Review Complete-Approved”)
{
return 1;
}
}

return 0;

Your scrip seemed to be looking for a "create" transaction. So it will 

only work if the CF value is what your looking for “at the time of
creation” ONLY. Whereas mine is merely looking for when the CF has been
altered, WHENEVER. Also, keep in mind is that there is case-sensitivity
in all comparisons.
Hope this helps.

Kenn
LBNLOn 3/4/2009 2:46 AM, Paul Vlaar wrote:

We’re trying to base our autoreply on the value of a custom field that
applies to a group. So I’ve created a scrip that applies to a queue:

Condition: User Defined
Action: Autoreply To Requestors
Template: Global template: Contract Expiring
Stage: TransactionCreate

In the Custom condition this should only trigger when the custom field
"Contract Status" equals “expiring”:

if ( $self->TransactionObj->Type eq “Create” &&
$self->TicketObj->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring" )
return 1;
} else {
return 0;
}

I’ve also tried:

$self->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring"

But this code doesn’t trigger the template and I can’t seem to find a
similar example of the use of custom group fields anywhere.

Thanks,

~paul

Hi Kenneth,

Thanks for your response. My scrip is indeed looking for a "create"
transaction because it should only trigger at the time of creation, and
the CF value is rather static, as it applies to the Group that the Queue
in which the ticket belongs, has rights to. I realise now that finding
that relationship is a bit difficult, and it’s probably better to move
the custom field to the Queue, instead.

~paulOn Wed Mar 04 2009 19:39:09 GMT+0100 (CET), Kenneth Crocker wrote:

Paul,

I use the following scrip for the condition and it works for me:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’)
{my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,
Name => “Review Process”);
return 0 unless $cf->id;
if ($trans->Field == $cf->id &&
$trans->NewValue eq “Review Complete-Approved”)
{
return 1;
}
}

return 0;

Your scrip seemed to be looking for a “create” transaction. So it will
only work if the CF value is what your looking for “at the time of
creation” ONLY. Whereas mine is merely looking for when the CF has been
altered, WHENEVER. Also, keep in mind is that there is case-sensitivity
in all comparisons.
Hope this helps.

Kenn
LBNL

On 3/4/2009 2:46 AM, Paul Vlaar wrote:

We’re trying to base our autoreply on the value of a custom field that
applies to a group. So I’ve created a scrip that applies to a queue:

Condition: User Defined
Action: Autoreply To Requestors
Template: Global template: Contract Expiring
Stage: TransactionCreate

In the Custom condition this should only trigger when the custom field
"Contract Status" equals “expiring”:

if ( $self->TransactionObj->Type eq “Create” &&
$self->TicketObj->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring" )
return 1;
} else {
return 0;
}

I’ve also tried:

$self->GroupObj->FirstCustomFieldValue(“Contract Status”) eq
"expiring"

But this code doesn’t trigger the template and I can’t seem to find a
similar example of the use of custom group fields anywhere.

Thanks,

~paul


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Paul_Vlaar@isc.org - ISC Operations - +1 650 423 1349 - PGP 0x294EC062

I’ve used your example Kenneth, with slight alternations, but this
doesn’t trigger:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’) {
my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id, Name => “Contract”);

  return 1 unless $cf->id;

  if  ($trans->Field == $cf->id && $trans->NewValue eq "expiring") {
        return 1;
  }

}

I’ve also tried $trans->Value but it’s still not working.

Is there any way to debug this stuff?

~paulOn Wed Mar 04 2009 19:39:09 GMT+0100 (CET), Kenneth Crocker wrote:
I use the following scrip for the condition and it works for me:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’)
{my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,
Name => “Review Process”);
return 0 unless $cf->id;
if ($trans->Field == $cf->id &&
$trans->NewValue eq “Review Complete-Approved”)
{
return 1;
}
}

return 0;

Paul_Vlaar@isc.org - ISC Operations - +1 650 423 1349 - PGP 0x294EC062

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’) {
my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id, Name => “Contract”);

  return 1 unless $cf->id;

This is actually a “return 0”, but I had it set to 1 for debugging.

  if  ($trans->Field == $cf->id && $trans->NewValue eq "expiring") {
        return 1;
  }

}

Paul_Vlaar@isc.org - ISC Operations - +1 650 423 1349 - PGP 0x294EC062

Paul,

Are yosaying it NEVER triggered? If so, then I suggest you look at 

your logs. Also, double check your values. Everything is case-sensitive.
If the value you are checking for doesn’t exist in the Custom Field
EXACTLY as what you are checking for, it won’t trigger. Otherwise, the
code looks good. It should work.
You did NOT put in the default Return 0; at the end. That should be
there so that the scrip doesn’t trigger if NONE of the conditions match.
But that wouldn’t keep it FROM triggering. I think it is a false value.
Let me know.

Kenn
LBNLOn 3/13/2009 12:00 PM, Paul Vlaar wrote:

On Fri Mar 13 2009 19:58:17 GMT+0100 (CET), Paul Vlaar wrote:

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if ($trans->Type eq ‘CustomField’) {
my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id, Name => “Contract”);

  return 1 unless $cf->id;

This is actually a “return 0”, but I had it set to 1 for debugging.

  if  ($trans->Field == $cf->id && $trans->NewValue eq "expiring") {
        return 1;
  }

}