Problem calling a custom scrip

All,

In 3.8.4, I am attempting to set up an approval queue. The idea is that if a Custom Field named “Change Control” is set to value 'YES" then a new ticket will be created to gather the required approval.

This is in queue “Monitoring”.

So, in the queue I have a Scrip: Monitor:approval, with a User Defined condition, Action is Create Tickets, Template is Monitor:Approval, Stage TransactionComplete.
My Custom Condition originally was:

if ($self->TransactionObj->Type ne “Create”) {
return 0; # This is an update transaction
}

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
if ($self->TicketObj->FirstCustomFieldValue(‘Change Control’) =~ /Yes/i) {
return 1;
}

return 0;

When that failed to do anything, I just changed it to “return 1;”.

My template is:

Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

When I create a ticket and select YES for my CF, I see this in my log; (note, my custom scrip is #84)

[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com #239/34524 - Scrip 3 On Create Autoreply To Requestors (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com sent To: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com #239/34524 - Scrip 4 On Create Notify AdminCcs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com No recipients found. Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:338)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com #239/34524 - Scrip 82 On Create Notify CCs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com sent Cc: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: Ticket 239 created in queue ‘Monitoring’ by SLANDER (/opt/rt3/bin/…/lib/RT/Ticket_Overlay.pm:667)

Can anyone see my mistake? Or, am I going about this wrong?

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

Hi Scott,

A couple of quick questions, from the logs it looks like the condition to
run your scrip is not being met, what do you have set for the condition of
your scrip? and What part of the transaction are you attaching the scrip to?

Thanks,
Bill G.
william.graboyes@theportalgrp.comOn Mon, Sep 14, 2009 at 2:19 PM, Lander, Scott slander@hearstsc.com wrote:

All,

In 3.8.4, I am attempting to set up an approval queue. The idea is
that if a Custom Field named “Change Control” is set to value 'YES" then a
new ticket will be created to gather the required approval.

This is in queue “Monitoring”.

So, in the queue I have a Scrip: Monitor:approval, with a User Defined
condition, Action is Create Tickets, Template is Monitor:Approval, Stage
TransactionComplete.
My Custom Condition originally was:

if ($self->TransactionObj->Type ne “Create”) {
return 0; # This is an update transaction
}

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
if ($self->TicketObj->FirstCustomFieldValue(‘Change Control’) =~ /Yes/i)
{
return 1;
}

return 0;

When that failed to do anything, I just changed it to “return 1;”.

My template is:

Subject: Approval of { $Tickets{‘TOP’}->Subject() }
Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

When I create a ticket and select YES for my CF, I see this in my log;
(note, my custom scrip is #84)

[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com> #239/34524 - Scrip 3 On
Create Autoreply To Requestors
(/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com> sent To:
slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com> #239/34524 - Scrip 4
On Create Notify AdminCcs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com> No recipients found.
Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:338)
[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com> #239/34524 - Scrip 82
On Create Notify CCs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: <
rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com> sent Cc:
slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: Ticket 239 created in queue ‘Monitoring’
by SLANDER (/opt/rt3/bin/…/lib/RT/Ticket_Overlay.pm:667)

Can anyone see my mistake? Or, am I going about this wrong?


This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.


The rt-users Archives

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

I changed my scrip to be:

if ($self->TransactionObj->Type ne “Create”) {
$RT::Logger->info( “> Not a Create \n” );
return 0; # This is an update transaction
}

my $ticket = $self->TicketObj;
my $CustomFields = $ticket->QueueObj->TicketCustomFields();

while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $val = $self->TicketObj->FirstCustomFieldValue($nam);
$RT::Logger->info( “> CustomField Name: $nam \n” );
$RT::Logger->info( “> CustomField Value: $val \n” );

if ($val =~ /YES/){
    $RT::Logger->info( ">  This is a change control \n" );
    return 1;
}

}

$RT::Logger->info( “> Default 0 exit \n” );
return 0;

And, now I see in the logs;

[Tue Sep 15 04:34:13 2009] [info]: > CustomField Name: Business Unit ((eval 1579):12)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Value: Charlotte ((eval 1579):13)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Name: Change Control ((eval 1579):12)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Value: YES ((eval 1579):13)
[Tue Sep 15 04:34:13 2009] [info]: > This is a change control ((eval 1579):16)
[Tue Sep 15 04:34:13 2009] [info]: <rt-3.8.4-3172-1252989253-875.246-3-0@hearstsc.commailto:rt-3.8.4-3172-1252989253-875.246-3-0@hearstsc.com> #246/34573 - Scrip 3 On Create Autoreply To Requestors (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)

So, by scrip is being called, but, no tickets are being created;

The scrip settings are;

Condition: User Defined (as above)
Action : Create Tickets
Template : Monitor:Approval
Stage : TransactionCreate

The only other part to this that I know of is the Template. Other then the template, is there anything else I need to do to auto create the approval tickets?

Here is my template;Subject: Approval of { $Tickets{‘TOP’}->Subject() }
Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.commailto:slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Lander, Scott
Sent: Monday, September 14, 2009 5:20 PM
To: ‘rt-users@lists.bestpractical.com’
Subject: [rt-users] Problem calling a custom scrip

All,

In 3.8.4, I am attempting to set up an approval queue. The idea is that if a Custom Field named “Change Control” is set to value 'YES" then a new ticket will be created to gather the required approval.

This is in queue “Monitoring”.

So, in the queue I have a Scrip: Monitor:approval, with a User Defined condition, Action is Create Tickets, Template is Monitor:Approval, Stage TransactionComplete.
My Custom Condition originally was:

if ($self->TransactionObj->Type ne “Create”) {
return 0; # This is an update transaction
}

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
if ($self->TicketObj->FirstCustomFieldValue(‘Change Control’) =~ /Yes/i) {
return 1;
}

return 0;

When that failed to do anything, I just changed it to “return 1;”.

My template is:

Subject: Approval of { $Tickets{‘TOP’}->Subject() }
Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

When I create a ticket and select YES for my CF, I see this in my log; (note, my custom scrip is #84)

[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com #239/34524 - Scrip 3 On Create Autoreply To Requestors (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com sent To: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com #239/34524 - Scrip 4 On Create Notify AdminCcs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com No recipients found. Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:338)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com #239/34524 - Scrip 82 On Create Notify CCs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com sent Cc: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: Ticket 239 created in queue ‘Monitoring’ by SLANDER (/opt/rt3/bin/…/lib/RT/Ticket_Overlay.pm:667)

Can anyone see my mistake? Or, am I going about this wrong?

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

After realizing my scrip was indeed being called (although not obvious from the original logs) I turned to the template.

With the following template, it all works.
Note, the ===Create-Ticket: line, and the ENDOFCONTENT lines are important, and the order of the lines seems to matter somewhat - IE, in the order shown on the RT-ESSENTIALS book, it wouldn’t work for me… Also, note that the Owner line refers to the ID of the owner, which may not be the email of the owner, depending on your system.

Template:

===Create-Ticket: manager-approvalSubject: Approval of {$Tickets{‘TOP’}->Subject}
Depended-On-By: TOP
Queue: ___Approvals
Type: approval
Owner: SLANDER
Refers-To: {$Tickets{‘TOP’}->Id()}

Content : Please review and approve this request.
ENDOFCONTENT

From: Lander, Scott
Sent: Tuesday, September 15, 2009 7:52 AM
To: Lander, Scott; ‘rt-users@lists.bestpractical.com’
Subject: RE: Problem calling a custom scrip - Update, but, still stuck.

I changed my scrip to be:

if ($self->TransactionObj->Type ne “Create”) {
$RT::Logger->info( “> Not a Create \n” );
return 0; # This is an update transaction
}

my $ticket = $self->TicketObj;
my $CustomFields = $ticket->QueueObj->TicketCustomFields();

while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $val = $self->TicketObj->FirstCustomFieldValue($nam);
$RT::Logger->info( “> CustomField Name: $nam \n” );
$RT::Logger->info( “> CustomField Value: $val \n” );

if ($val =~ /YES/){
    $RT::Logger->info( ">  This is a change control \n" );
    return 1;
}

}

$RT::Logger->info( “> Default 0 exit \n” );
return 0;

And, now I see in the logs;

[Tue Sep 15 04:34:13 2009] [info]: > CustomField Name: Business Unit ((eval 1579):12)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Value: Charlotte ((eval 1579):13)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Name: Change Control ((eval 1579):12)
[Tue Sep 15 04:34:13 2009] [info]: > CustomField Value: YES ((eval 1579):13)
[Tue Sep 15 04:34:13 2009] [info]: > This is a change control ((eval 1579):16)
[Tue Sep 15 04:34:13 2009] [info]: <rt-3.8.4-3172-1252989253-875.246-3-0@hearstsc.commailto:rt-3.8.4-3172-1252989253-875.246-3-0@hearstsc.com> #246/34573 - Scrip 3 On Create Autoreply To Requestors (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)

So, by scrip is being called, but, no tickets are being created;

The scrip settings are;

Condition: User Defined (as above)
Action : Create Tickets
Template : Monitor:Approval
Stage : TransactionCreate

The only other part to this that I know of is the Template. Other then the template, is there anything else I need to do to auto create the approval tickets?

Here is my template;

Subject: Approval of { $Tickets{‘TOP’}->Subject() }
Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.commailto:slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Lander, Scott
Sent: Monday, September 14, 2009 5:20 PM
To: ‘rt-users@lists.bestpractical.com’
Subject: [rt-users] Problem calling a custom scrip

All,

In 3.8.4, I am attempting to set up an approval queue. The idea is that if a Custom Field named “Change Control” is set to value 'YES" then a new ticket will be created to gather the required approval.

This is in queue “Monitoring”.

So, in the queue I have a Scrip: Monitor:approval, with a User Defined condition, Action is Create Tickets, Template is Monitor:Approval, Stage TransactionComplete.
My Custom Condition originally was:

if ($self->TransactionObj->Type ne “Create”) {
return 0; # This is an update transaction
}

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
if ($self->TicketObj->FirstCustomFieldValue(‘Change Control’) =~ /Yes/i) {
return 1;
}

return 0;

When that failed to do anything, I just changed it to “return 1;”.

My template is:

Subject: Approval of { $Tickets{‘TOP’}->Subject() }
Queue: ___Approvals
Type : approval
Owner : slander@hearstsc.com
Content : Please review and approve this request.
Depended-On-By : TOP

When I create a ticket and select YES for my CF, I see this in my log; (note, my custom scrip is #84)

[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com #239/34524 - Scrip 3 On Create Autoreply To Requestors (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-747.239-3-0@hearstsc.com sent To: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com #239/34524 - Scrip 4 On Create Notify AdminCcs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1595.239-4-0@hearstsc.com No recipients found. Not sending. (/opt/rt3/bin/…/lib/RT/Interface/Email.pm:338)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com #239/34524 - Scrip 82 On Create Notify CCs (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:302)
[Mon Sep 14 21:30:07 2009] [info]: rt-3.8.4-3173-1252963807-1456.239-82-0@hearstsc.com sent Cc: slander@hearstsc.com (/opt/rt3/bin/…/lib/RT/Action/SendEmail.pm:333)
[Mon Sep 14 21:30:07 2009] [info]: Ticket 239 created in queue ‘Monitoring’ by SLANDER (/opt/rt3/bin/…/lib/RT/Ticket_Overlay.pm:667)

Can anyone see my mistake? Or, am I going about this wrong?

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.

This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify the Hearst Service Center (cadmin@hearstsc.com) immediately by email and delete the original message.