RT 3.0.6 - Custom Scrip Conditions on Custom Field changes

Hi,

The custom scrip conditions in RT 3 is very powerfull, but I cannot
figure out how to trigger an action on a change to a “custom field”.

I’ve tried this to no avail:

if ($self->TransactionObj->Field eq “NameOfCustomField”) {
return(1);
} else {
return(undef);
}

What I really want to do is not just trigger on any change but trigger
on specific values of custom fields.

Eg: If (( custom field modified ) and ( custom field value =
“somevalue”)) return (1);

Any ideas?

-Bob

BJ Blanchard wrote:

Hi,

The custom scrip conditions in RT 3 is very powerfull, but I cannot
figure out how to trigger an action on a change to a “custom field”.

I’ve tried this to no avail:

if ($self->TransactionObj->Field eq “NameOfCustomField”) {
return(1);
} else {
return(undef);
}
Look at this:
mysql> select distinct Type,Field from Transactions;

So you must use CustomFieldId instead of Name.
To get ID from Name you can create new CF object and load it by name and
Tickets’s queue.
Good Luck. Ruslan.

Thanks Ruslan for pointing me in the right direction.

Just for others to see, this is what I got working:

if (($self->TransactionObj->Type eq “CustomField”) and
($self->TransactionObj->Field eq 2) and
($self->TransactionObj->NewValue eq “Critical Maintenance”)) {
return(1);
} else {
return(undef);
}

NOTE: I’m using the CustomFieldId of “2” above since I didn’t have time
to implement the lookup by name.

If anyone wants to contribute that part, that would be great.

Now I’m looking to build a custom scrip action which adds a ticket
watcher as a “Cc”.

There are no methods that I can see under TicketObj for doing this.

Anyone?On Fri, 2003-10-31 at 10:11, Ruslan U. Zakirov wrote:

BJ Blanchard wrote:

Hi,

The custom scrip conditions in RT 3 is very powerfull, but I cannot
figure out how to trigger an action on a change to a “custom field”.

I’ve tried this to no avail:

if ($self->TransactionObj->Field eq “NameOfCustomField”) {
return(1);
} else {
return(undef);
}
Look at this:
mysql> select distinct Type,Field from Transactions;

So you must use CustomFieldId instead of Name.
To get ID from Name you can create new CF object and load it by name and
Tickets’s queue.
Good Luck. Ruslan.

What I really want to do is not just trigger on any change but trigger
on specific values of custom fields.

Eg: If (( custom field modified ) and ( custom field value =
“somevalue”)) return (1);

Any ideas?

-Bob


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm

BJ Blanchard wrote:

Thanks Ruslan for pointing me in the right direction.

Just for others to see, this is what I got working:

if (($self->TransactionObj->Type eq “CustomField”) and
If you have upgraded from 2.x to 3.x then Type could be ‘Keyword’ also.
($self->TransactionObj->Field eq 2) and
($self->TransactionObj->NewValue eq “Critical Maintenance”)) {
return(1);
} else {
return(undef);
}
I recommend you to avoid usage of ID.

NOTE: I’m using the CustomFieldId of “2” above since I didn’t have time
to implement the lookup by name.

If anyone wants to contribute that part, that would be great.

Now I’m looking to build a custom scrip action which adds a ticket
watcher as a “Cc”.
Why? ‘Notify Requestors, Ccs and AdminCcs’ - it’s all watchers in RT.

There are no methods that I can see under TicketObj for doing this.

Anyone?
Look here:
select * from ScripActions where ExecModule LIKE ‘Notify%’;

Now I’m looking to build a custom scrip action which adds a ticket
watcher as a “Cc”.
Why? ‘Notify Requestors, Ccs and AdminCcs’ - it’s all watchers in RT.

I don’t want to notify, I want to add a watcher. Business scenario is
this: If a ticket is Critical (custom field condition), then add
manager to Cc list for ticket… ie. don’t want to watch the queue, only
tickets flaged critical.

BJ.

BJ Blanchard wrote:

Now I’m looking to build a custom scrip action which adds a ticket
watcher as a “Cc”.

Why? ‘Notify Requestors, Ccs and AdminCcs’ - it’s all watchers in RT.

I don’t want to notify, I want to add a watcher. Business scenario is
this: If a ticket is Critical (custom field condition), then add
manager to Cc list for ticket… ie. don’t want to watch the queue, only
tickets flaged critical.

BJ.

Sorry for that.
my ($status, $msg) = $TicketObj->AddWatcher(Type => ‘Cc’, Email =>
‘foo@bar.com’);
die $msg unless( $status );