[rt-users] Rép. : Re: Custom scrip : $cf->id is empty

Horst Kriegers Horst.Kriegers at loro.ch
Tue Nov 9 01:16:20 EST 2010


I think I've founded the problem.
The CF was moved from queues to Global so that all queues have an
access to this CF.
 
I need to make some tests, but I think that it  changes below want to
resolve my problem.
Is this the correct way ? Or maybe have you a better suggestion ?
 
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $myCfName = "Qualification sécurité";
 
$RT::Logger->debug('***************************************');
 
if ($trans->Type eq 'CustomField') {
  my $cf = new RT::CustomField($RT::SystemUser);
  $cf->LoadById($trans->Field);
  ##return 0 unless $cf->id;
...
...
  if ($cf->Name == $myCfName && $trans->NewValue eq "Oui") {
    ...
    ...

 
 


>>> Le Lundi, 8. Novembre 2010 à  19:11, Kevin Falcone
<falcone at bestpractical.com> a écrit :

On Fri, Nov 05, 2010 at 02:09:33PM +0100, Horst Kriegers wrote:
>    Hello,
> 
>    we have freshly migrated from 3.6.6 to 3.8.8 and the following
custom scrip doesn't work.
> 
>    If I comment the line 12 "return 0 unless $cf->id;", I can see
that the $cf->id and $cf->Name
>    are empty
> 
> 
> 
>    my $trans = $self->TransactionObj;
>    my $ticket = $self->TicketObj;
> 
>    $RT::Logger->debug('***************************************');
>    $RT::Logger->debug('>> trans->Type = ' . $trans->Type);
> 
>    if ($trans->Type eq 'CustomField') {
>      my $cf = new RT::CustomField($RT::SystemUser);
>      $cf->LoadByName(Queue => $ticket->QueueObj->id, Name =>
"Qualification securite");

You want to be capturing

my ($ok, $msg) = $cf->LoadByName

and warning out the $msg to see why it isn't loading

>      ###return 0 unless $cf->id;
> 
>      $RT::Logger->debug('>> cf->id = ' . $cf->id);
>      $RT::Logger->debug('>> cf->Name = ' . $cf->Name);
>      $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->Field == $cf->id && $trans->NewValue eq "Oui") {
>        $RT::Logger->debug($cf->Name . '  OUI.');
>        return 1;
>      } else {
>        $RT::Logger->debug($cf->Name . ' pas  OUI.');
>      }
>    }
>    $RT::Logger->debug('***************************************');
> 
>    return 0;
> 
> 
> 
>    Logger result :
>    ------------------
>    [Fri Nov  5 13:07:14 2010] [debug]:
*************************************** ((eval 5328):5)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> trans->Type = CustomField
((eval 5328):6)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> cf->id =  ((eval 5328):14)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> cf->Name =  ((eval
5328):15)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> trans->Field = 4 ((eval
5328):16)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> trans->NewValue = Non
((eval 5328):17)
>    [Fri Nov  5 13:07:14 2010] [debug]: >> trans->OldValue = Oui
((eval 5328):18)
>    [Fri Nov  5 13:07:14 2010] [debug]:  ((eval 5328):19)
>    [Fri Nov  5 13:07:14 2010] [debug]:  pas  OUI. ((eval 5328):25)
>    [Fri Nov  5 13:07:14 2010] [debug]:
*************************************** ((eval 5328):28)
> 
> 
> 
>    Thanks in advance for your help.
>    Horst
> 
> 
>    PS
>    Sorry for my bad english...
> 
>   
_______________________________________________________________________
> 
>    Le contenu de ce courriel est uniquement reserve `a la personne ou
l'organisme `a qui il est
>    destine. Si vous n'etes pas le destinataire prevu, veuillez nous
en informer au plus vite et
>    detruire le present courriel. Dans ce cas, il ne vous est pas
permis de copier ce courriel, de
>    le distribuer ou de l'utiliser de quelque maniere 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.
___________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20101109/a91d2565/attachment.htm>


More information about the rt-users mailing list