CustomField Transactions Options?

I have a custom field entry that when selected, I want to automatically add a
watcher to the ticket in question. As it stands, this CustomField called
‘Service Type’ has an entry for PO’s that when selected should add
‘purchasing@fibermedia.net’ as a watcher without having the operator
manually add the entry. I don’t see anywhere in the customfield options to
add a watcher, only to notify existing individuals associated with the
ticket. Anyone got any input on this?

View this message in context: http://requesttracker.8502.n7.nabble.com/CustomField-Transactions-Options-tp54412.html

I have a custom field entry that when selected, I want to automatically add a
watcher to the ticket in question. As it stands, this CustomField called
‘Service Type’ has an entry for PO’s that when selected should add
‘purchasing@fibermedia.net’ as a watcher without having the operator
manually add the entry. I don’t see anywhere in the customfield options to
add a watcher, only to notify existing individuals associated with the
ticket. Anyone got any input on this?

You have to do this with a “scrip”.

Your scrip can be global or only on some queues.

As scrip condition, you have to write your own by selecting “User
defined”. You’re condition shoudl check that this transactions happens
on this CustomField and matches the wanted change.
As scrip action, you have also to write your own as “User defined”, and
use the appropriate method of the RT API
(RT::Ticket - RT 4.0.25 Documentation - Best Practical) to
add the watcher.
As a template, you can select “blank”.

Easter-eggs Sp�cialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - M�tro Gait�
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

I have a custom field entry that when selected, I want to automatically add a
watcher to the ticket in question. As it stands, this CustomField called
‘Service Type’ has an entry for PO’s that when selected should add
‘purchasing@fibermedia.net’ as a watcher without having the operator
manually add the entry. I don’t see anywhere in the customfield options to
add a watcher, only to notify existing individuals associated with the
ticket. Anyone got any input on this?

There is no built in action for that, you’d need to write a simple
User Defined action to call
$TicketObj->AddWatcher(…)

http://bestpractical.com/rt/docs/latest/RT/Ticket.html#AddWatcher

-kevin

Hi mloughran,

I have a custom field entry that when selected, I want to automatically add a
watcher to the ticket in question. As it stands, this CustomField called
‘Service Type’ has an entry for PO’s that when selected should add
‘purchasing@fibermedia.net’ as a watcher without having the operator
manually add the entry. I don’t see anywhere in the customfield options to
add a watcher, only to notify existing individuals associated with the
ticket. Anyone got any input on this?

I ran into a quite similar case just a few months ago.

You have to do this with a “scrip”.

Our Custom Condition Code checks if the customfield ‘Severity’ is changed:

return 0 unless $self->TransactionObj->Type eq 'CustomField';
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->SetContextObject( $self->TransactionObj );
$cf->Load( $self->TransactionObj->Field );
return 1 if $cf->Name() eq 'Severity';

return 0;

And for our custom action prepare (or cleanup, I never know which to pick):

for ($self->TransactionObj->NewValue) {
    if (m/^Major$/) {
        $self->TicketObj->AddWatcher(Type => 'Requestor', Email => 'major-incident@name.local');
    }
    elsif (m/^Critical$/) {
        $self->TicketObj->AddWatcher(Type => 'Requestor', Email => 'critical-incident@name.local');
    }
}

for ($self->TransactionObj->OldValue) {
    if ( m/^Critical$/ ) {
         $self->TicketObj->DeleteWatcher(Type => 'Requestor', Email => 'critical-incident@name.local');
    }
    elsif ( m/^Major$/ ) {
         $self->TicketObj->DeleteWatcher(Type => 'Requestor', Email => 'major-incident@name.local');
    }
}

return 1;

The added (or removed) watcher addresses expand to SMS in this case.

Regards,
Kai

signature.asc (906 Bytes)

And for our custom action prepare (or cleanup, I never know which to pick):

Prepare should be used to do any work needed to do the action’s
business, or to check some further conditions (depends on the action).

No changes should ever be made in prepare since it may be called more
than once. All changes should happen in “cleanup” (which is renamed to
commit in 4.2).