Script : custom action by ticket creation or modification

Hello,

the following scrip works only “On transaction” but not wen a new
ticket is created.
What is wrong ?

  • Condition : User Defined
  • Custom condition :

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 =>
“Qualification sécurité”);
return 0 unless $cf->id;

if ($trans->Field == $cf->id && $trans->NewValue eq “Oui”) {
return 1;
}

}
return 0;

Thanks in advance for your help.
Horst

Le contenu de ce courriel est uniquement réservé à la personne ou
l’organisme à qui il est destiné. Si vous n’êtes pas le destinataire
prévu, veuillez nous en informer au plus vite et détruire le présent
courriel. Dans ce cas, il ne vous est pas permis de copier ce courriel,
de le distribuer ou de l’utiliser de quelque manière que ce soit.

The content of this e-mail is intended only and solely for the use
of the named recipient or organisation. If you are not the named
recipient, please inform us immediately and delete the present e-mail.
In this case, you are nor allowed to copy, distribute or use this
e-mail in any way.

the following scrip works only “On transaction” but not wen a new ticket is created.
What is wrong ?

Your condition says “only work when this is a custom field change”, it
doesn’t consider Create types at all.

-kevin

Hello,

sorry, I don’t understand how to consider the Ticket Creating.
Can you assist me ?

Thanks a lot
Horst

the following scrip works only “On transaction” but not wen a new
ticket is created.
What is wrong ?

Your condition says “only work when this is a custom field change”, it
doesn’t consider Create types at all.

-kevin

  • Condition : User Defined
  • Custom condition :

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 =>
“Qualification securite”);
return 0 unless $cf->id;

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

}
return 0;

Le contenu de ce courriel est uniquement réservé à la personne ou
l’organisme à qui il est destiné. Si vous n’êtes pas le destinataire
prévu, veuillez nous en informer au plus vite et détruire le présent
courriel. Dans ce cas, il ne vous est pas permis de copier ce courriel,
de le distribuer ou de l’utiliser de quelque manière que ce soit.

The content of this e-mail is intended only and solely for the use
of the named recipient or organisation. If you are not the named
recipient, please inform us immediately and delete the present e-mail.
In this case, you are nor allowed to copy, distribute or use this
e-mail in any way.

Hort,

Try this:

Check for Ticket Status changed to “Created”

my $trans = $self->TransactionObj;

return 0 unless ($trans->Type eq “Status” &&
$trans->NewValue eq “Create”);

Then follow with your code.

Kenn
LBNLOn Fri, Nov 5, 2010 at 7:25 AM, Horst Kriegers Horst.Kriegers@loro.chwrote:

Hello,

sorry, I don’t understand how to consider the Ticket Creating.
Can you assist me ?

Thanks a lot
Horst

Le Mardi, 29. Juin 2010 à 17:01, Kevin Falcone < falcone@bestpractical.com> a écrit :
On Tue, Jun 29, 2010 at 10:09:19AM +0200, Horst Kriegers wrote:
the following scrip works only “On transaction” but not wen a new
ticket is created.
What is wrong ?

Your condition says “only work when this is a custom field change”, it
doesn’t consider Create types at all.

-kevin

  • Condition : User Defined
  • Custom condition :

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 =>
“Qualification securite”);
return 0 unless $cf->id;

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

}
return 0;


Le contenu de ce courriel est uniquement réservé à la personne ou
l’organisme à qui il est destiné. Si vous n’êtes pas le destinataire prévu,
veuillez nous en informer au plus vite et détruire le présent courriel. Dans
ce cas, il ne vous est pas permis de copier ce courriel, de le distribuer ou
de l’utiliser de quelque manière que ce soit.


The content of this e-mail is intended only and solely for the use of the
named recipient or organisation. If you are not the named recipient, please
inform us immediately and delete the present e-mail. In this case, you are
nor allowed to copy, distribute or use this e-mail in any way.


I am not enough good, I am lost :frowning:
Now, I really need help because I do not manage to resolve my problem.

What I wish to obtain :
By creating a new ticket, or by updating an existing ticket : if the CF
declared in $myCfName is set to “Oui” , I need to execute the selected
action based on the selected Template

Scrip Condition : User Defined

The code which I have at present :
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $myCfName = “Qualification sécurité”;

return 0 unless ($trans->Type eq “Status” && $trans->NewValue eq
“Create”);

$RT::Logger->debug(‘>> $trans->Type = ’ . $trans->Type);
$RT::Logger->debug(’>> $trans->Field = ’ . $trans->Field);
$RT::Logger->debug(‘>> $trans->NewValue = ’ . $trans->NewValue);
$RT::Logger->debug(’>> $trans->OldValue = ’ . $trans->OldValue);

$RT::Logger->debug(‘***************************************’);

if ($trans->Type eq ‘CustomField’) {

my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadById($trans->Field);
return 0 unless $cf->id;

$RT::Logger->debug(‘>> $myCfName = ’ . $myCfName);
$RT::Logger->debug(’>> $cf->id = ’ . $cf->id);
$RT::Logger->debug(‘>> $cf->Name = ’ . $cf->Name);
$RT::Logger->debug(’>> $cf->Type = ’ . $cf->Type);
$RT::Logger->debug(‘>> $cf->MaxValues = ’ . $cf->MaxValues);
$RT::Logger->debug(’>> $cf->Pattern = ’ . $cf->Pattern);
$RT::Logger->debug(‘>> $cf->Description = ’ . $cf->Description);
$RT::Logger->debug(’>> $cf->Creator = ’ . $cf->Creator);
$RT::Logger->debug('>> $cf->Created = ’ . $cf->Created);

$RT::Logger->debug(‘>> $trans->Type = ’ . $trans->Type);
$RT::Logger->debug(’>> $trans->Field = ’ . $trans->Field);
$RT::Logger->debug(‘>> $trans->NewValue = ’ . $trans->NewValue);
$RT::Logger->debug(’>> $trans->OldValue = ’ . $trans->OldValue);
$RT::Logger->debug(‘’);

$RT::Logger->debug(‘-------------------------’);
$RT::Logger->debug(‘- ‘. $cf->Name .’ == ’ . $myCfName);
$RT::Logger->debug(’- Valeur = ’ . $trans->NewValue);

if ($cf->Name == $myCfName && $trans->NewValue eq “Oui”) {
$RT::Logger->debug(‘->Action exécutée…’);
return 1;
} else {
$RT::Logger->debug(‘-> Action PAS exécutée…’);
}

}
$RT::Logger->debug(‘***************************************’);

return 0;

A big THANKS four your help.
Horst

Hort,

Try this:

Check for Ticket Status changed to “Created”

my $trans = $self->TransactionObj;

return 0 unless ($trans->Type eq “Status” &&
$trans->NewValue eq “Create”);

Then follow with your code.

Kenn
LBNL

Hello,
sorry, I don’t understand how to consider the Ticket Creating.
Can you assist me ?
Thanks a lot
Horst

the following scrip works only “On transaction” but not wen a new
ticket is created.
What is wrong ?

Your condition says “only work when this is a custom field change”, it
doesn’t consider Create types at all.

-kevin

  • Condition : User Defined
  • Custom condition :

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 =>
“Qualification securite”);
return 0 unless $cf->id;

if ($trans->Field == $cf->id && $trans->NewValue eq “Oui”) {
return 1;
}

}
return 0;

Le contenu de ce courriel est uniquement réservé à la personne ou
l’organisme à qui il est destiné. Si vous n’êtes pas le destinataire
prévu, veuillez nous en informer au plus vite et détruire le présent
courriel. Dans ce cas, il ne vous est pas permis de copier ce courriel,
de le distribuer ou de l’utiliser de quelque manière que ce soit.

The content of this e-mail is intended only and solely for the use of
the named recipient or organisation. If you are not the named recipient,
please inform us immediately and delete the present e-mail. In this
case, you are nor allowed to copy, distribute or use this e-mail in any
way.

Le contenu de ce courriel est uniquement réservé à la personne ou
l’organisme à qui il est destiné. Si vous n’êtes pas le destinataire
prévu, veuillez nous en informer au plus vite et détruire le présent
courriel. Dans ce cas, il ne vous est pas permis de copier ce courriel,
de le distribuer ou de l’utiliser de quelque manière que ce soit.

The content of this e-mail is intended only and solely for the use
of the named recipient or organisation. If you are not the named
recipient, please inform us immediately and delete the present e-mail.
In this case, you are nor allowed to copy, distribute or use this
e-mail in any way.