Custom Conditions

Hi,

Can anyone tell me what the custom condition box in Scrips is for? Can I
type Perl scripts directly into to it to, for example, dump mail into
particular queues depending on the subject line?

Any help would be much appreciated, as always.

Regards,

Dermot Williams
Technical Support Engineer
Irish Broadband Internet Services

Hi,

Can anyone tell me what the custom condition box in Scrips is for? Can I
type Perl scripts directly into to it to, for example, dump mail into
particular queues depending on the subject line?

Any help would be much appreciated, as always.

For conditions that aren’t available in the Condition selection menu.

Use perl, just make it return true or false.

For example:

undef unless ($self->TicketObj->Subject =~ m/foo/ or $self->TicketObj->Subject =~ m/bar/ );

But the queue has an e-mail address, so doing a queue change is
probably complicating something that doesn’t need to be complicated.

Andy Harrison
(full headers for details)

The trouble being that without a definitive list of objects and their
methods it makes it tricky to use…

Andy Harrison wrote:

Subject: “[rt-users] Custom Conditions”



> Hi,
>
> Can anyone tell me what the custom condition box in Scrips is for? Can I
> type Perl scripts directly into to it to, for example, dump mail into
> particular queues depending on the subject line?
>
> Any help would be much appreciated, as always.


For conditions that aren't available in the Condition selection menu.

Use perl, just make it return true or false.

For example:

undef unless ($self->TicketObj->Subject =~ m/foo/ or $self->TicketObj->Subject =~ m/bar/ );

But the queue has an e-mail address, so doing a queue change is
probably complicating something that doesn't need to be complicated.

With regards,

Say_Ten

This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it.

In the event of misdirection, illegible or incomplete transmission please telephone (023) 8024 3137
or return the E.mail to postmaster@multiplay.co.uk.

The trouble being that without a definitive list of objects and their
methods it makes it tricky to use…

That’s putting it mildly. :slight_smile:

Here’s a trick I got from one of the saints.

I was using it in a template to see what was available.

Template Content:

{
require ‘/tmp/Symbol/Methods.pm’;
print “::::\n”;
foreach ( Symbol::Methods::probesym( ref $Ticket ) ) { print; print “\n”; }
print “::::\n”;
}

Then you could do: my $Transactions = $Ticket->Transactions and ref
$Transactions to see the next level.

cat /tmp/Symbol/Methods.pm

package Symbol::Methods;

sub probesym {
my $pkg = shift || ‘main’;
my $seen = shift || { };

my @subs;

foreach my $class ( @{ $pkg . ‘::ISA’ } ) {
push @subs, probesym($class, $seen)
unless $seen{$class}++;
}

push @subs,
grep UNIVERSAL::can( $pkg, $_ ),
values %{ $pkg . ‘::’ };

@subs;
}

1;

Andy Harrison
(full headers for details)

Hello.
I’m not a saint,
I just insane,
but use an easy way :slight_smile:
perldoc and vi could help a lot :slight_smile:

In custom condition code you can use:
$self->TicketObj
$self->TransactionObj
$self->ScripObj

then
perldoc /opt/rt3/lib/RT/Ticket.pm
perldoc /opt/rt3/lib/RT/Ticket_Overlay.pm
perldoc /opt/rt3/lib/RT/Tickets.pm
perldoc /opt/rt3/lib/RT/Tickets_Overlay.pm
perldoc /opt/rt3/lib/RT/Transaction.pm
perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm
perldoc /opt/rt3/lib/RT/Transactions.pm
perldoc /opt/rt3/lib/RT/Transactions_Overlay.pm

Isn’t it enought???
Best regards. Ruslan.
Andy Harrison wrote:

In custom condition code you can use:
$self->TicketObj
$self->TransactionObj
$self->ScripObj

then
perldoc /opt/rt3/lib/RT/Ticket.pm
perldoc /opt/rt3/lib/RT/Ticket_Overlay.pm
perldoc /opt/rt3/lib/RT/Tickets.pm
perldoc /opt/rt3/lib/RT/Tickets_Overlay.pm
perldoc /opt/rt3/lib/RT/Transaction.pm
perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm
perldoc /opt/rt3/lib/RT/Transactions.pm
perldoc /opt/rt3/lib/RT/Transactions_Overlay.pm

Isn’t it enought???
Best regards. Ruslan.

Not even close. In templates, for example, where is
$Ticket->Transactions->First->Content documented?

Andy Harrison
Great Works Internet
System Operations
(full headers for details)

Andy Harrison
(full headers for details)

Andy Harrison wrote:

Subject: “Re: [rt-users] Custom Conditions”



> In custom condition code you can use:
> 	$self->TicketObj
> 	$self->TransactionObj
> 	$self->ScripObj
>
> then
> perldoc /opt/rt3/lib/RT/Ticket.pm
> perldoc /opt/rt3/lib/RT/Ticket_Overlay.pm
> perldoc /opt/rt3/lib/RT/Tickets.pm
> perldoc /opt/rt3/lib/RT/Tickets_Overlay.pm
> perldoc /opt/rt3/lib/RT/Transaction.pm
> perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm
> perldoc /opt/rt3/lib/RT/Transactions.pm
> perldoc /opt/rt3/lib/RT/Transactions_Overlay.pm
>
> Isn't it enought???
> 		Best regards. Ruslan.



Not even close.  In templates, for example, where is
$Ticket->Transactions->First->Content documented?
                  ^^^ this s mean collection(First, Next, Last)

perldoc DBIx::SearchBuilder
Each element in collection is:
perldoc /opt/rt3/lib/RT/Transaction.pm
perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm

Just vi RT code will tell you a lot. :slight_smile:

UNIVERSAL::can hide AUTOLOAD functions from you.
Good luck. Ruslan.

Not even close. In templates, for example, where is
$Ticket->Transactions->First->Content documented?
^^^ this s mean collection(First, Next, Last)
perldoc DBIx::SearchBuilder
Each element in collection is:
perldoc /opt/rt3/lib/RT/Transaction.pm
perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm

Ah, I see. Even the manual from Jesse’s class only documents Next.
Although there is still nothing to indicate that ->Content is
available to First.

Just vi RT code will tell you a lot. :slight_smile:

UNIVERSAL::can hide AUTOLOAD functions from you.
Good luck. Ruslan.

Viewing the source code is not documentation if you don’t understand
advanced perl and objects/inheritence/references/etc…

Andy Harrison
(full headers for details)

At Friday 3/5/2004 12:30 PM, Andy Harrison wrote:

Not even close. In templates, for example, where is
$Ticket->Transactions->First->Content documented?
^^^ this s mean collection(First, Next, Last)
perldoc DBIx::SearchBuilder
Each element in collection is:
perldoc /opt/rt3/lib/RT/Transaction.pm
perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm

Ah, I see. Even the manual from Jesse’s class only documents Next.
Although there is still nothing to indicate that ->Content is
available to First.

Andy,

I think there is - you just need to decipher the OO Perl syntax and use this
to navigate the path through the perldocs:

  • $Ticket is a Ticket object - look at the perldoc for RT::Ticket (& _Overlay)
    and you will find that:
  • Ticket has a method called Transactions that returns a Transactions object.
    In perldoc RT::Transactions you will find that:
  • Transactions has method First that returns a Transaction object -
    In perldoc RT::Transaction you will see:
  • Transaction has method Content which returns the transaction’s content.

It sounds like a good entry for the wiki FAQ would be ‘what RT objects are
available to me in scrips & templates?’. I’m willing to draft an answer
based on Ruslan’s contributions to this thread.

Can someone confirm that the naming convention means that the variable
names are composed from base class name + “Obj” - for example the ticket
object is called TicketObj?

Steve

At Friday 3/5/2004 12:55 PM, Stephen Turner wrote:

  • Ticket has a method called Transactions that returns a Transactions object.

In perldoc RT::Transactions you will find that:

  • Transactions has method First that returns a Transaction object -
    In perldoc RT::Transaction you will see:

Correction:

perldoc for RT::Transactions does not tell about the First method.
Looking at the code in Transactions.pm tells us that Transactions is
subclassed from RT::SearchBuilder which is in turn subclassed from
DBIx::SearchBuilder. The last one is where the First method is defined.

It actually would be nice if the RT perldoc included the super classes.

Steve

It actually would be nice if the RT perldoc included the super classes.

It would be nice if perldoc had a way to include the superclasses :confused:

PGP.sig (186 Bytes)

At Friday 3/5/2004 01:16 PM, Jesse Vincent wrote:

It actually would be nice if the RT perldoc included the super classes.

It would be nice if perldoc had a way to include the superclasses :confused:

Well it has no automated way of doing this - but what’s to stop us
from putting that information in, say, the DESCRIPTION section of
the RT base class modules? It would need to be maintained manually,
but then that’s the case for all of the embedded code documentation.

Steve

Does anyone feel like setting up a copy of CPANXR for RT?On Mar 5, 2004, at 1:47 PM, Stephen Turner wrote:

At Friday 3/5/2004 01:16 PM, Jesse Vincent wrote:

It actually would be nice if the RT perldoc included the super
classes.

It would be nice if perldoc had a way to include the superclasses :confused:

Well it has no automated way of doing this - but what’s to stop us
from putting that information in, say, the DESCRIPTION section of
the RT base class modules? It would need to be maintained manually,
but then that’s the case for all of the embedded code documentation.

Steve


rt-users mailing list
rt-users@lists.bestpractical.com
The rt-users Archives

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