[rt-users] Custom Field values are being deleted on ticket modification

Ken Crocker kfcrocker at lbl.gov
Wed Dec 16 12:12:00 EST 2009


Luis,

I had trouble awhile back with Custom Field values not being set at all 
during the execution of a scrip, while all other changes took place 
correctly. The cause turned out to be that I had set the stage in the 
scrips to "TransactionCreate" instead of "TransactionBatch". Try that. 
Remember, you have to turn on "TransactionBatch" in your 
RT_SiteConfiguration.pm file and bounce your session.

Kenn
LBNL

On 12/16/2009 6:38 AM, Luis E. Muñoz wrote:
> Hi there,
>
> I am working on a customization script that should issue a number of
> configuration changes in a vainilla RT 3.6.7 as shipped with Debian
> Lenny.
>
> The snippet below should create 4 custom fields that would apply to the
> General queue, and add a couple of test values to them:
>
> #!/usr/bin/perl
> use lib '/usr/share/request-tracker3.6/lib';
> use strict; use warnings; use RT; use RT::User; use RT::Queue;
> use RT::Template; 
> RT::LoadConfig;
> RT::Init;
>
> for my $d ( [ Field1  => 'My Field 1', { One   => 'Value One',
> Two   => 'Value Two', }],
>     [ Field2  => 'My Field 2', { One   => 'Value One',
> Two   => 'Value Two', }],
>     [ Field3  => 'My Field 3', { One   => 'Value One',
> Two   => 'Value Two', }],
>     [ Field4  => 'My Field 4', { One   => 'Value One',
> Two   => 'Value Two', }],)
> {
>     my $cf = new RT::CustomField ( $RT::SystemUser );
>     my ($id, $msg) = $cf->Create(
> Name => $d->[0],
> Description => $d->[1],
> Type => 'Combobox',
> LookupType => 'RT::Queue-RT::Ticket',
> Pattern => '(?#Mandatory).',
> );
>     print 'Cannot create CF ' . $d->[0] . ": $msg\n" unless $id;
>     my $order = 0;
>     for my $val (sort keys %{$d->[2]})
>     {
> my ($d, $msg) = $cf->AddValue(Name => $d->[2]->{$val}, 
>       Description => $d->[2]->{$val},
>       SortOrder => $order);
> print "Value $val: $msg \n";
> $order += 5;
>     }
>
>     for my $queue (qw/General/)
>     {
> my $q = RT::Queue->new($RT::SystemUser);
> $q->Load($queue);
> my ($id, $msg) = $cf->AddToObject($q);
> print "Can't link CF to queue $queue: $msg\n" unless $id;
>     }
> }
>
> After the script is run, I can see the fields through Configuration >
> Custom Fields, with the intended values. When I try to create a ticket
> in the General queue, the corresponding combo boxes are populated with
> the expected values. So far so good.
>
> When the ticket is created, the CF values are stored along with the
> ticket and I can see them in the display.
>
> Whenever I try to change the ticket (say, modify the value of a CF), the
> following messages are displayed in my browser before the Basic form:
>
>   * Value Two added as a value for Field1 
>       * Value Two is no longer a value for custom field Field2 
>       * Value Two is no longer a value for custom field Field3 
>       * Value One is no longer a value for custom field Field4
>
> The ticket losses the CF values... This is what the logs say.
>
> Dec 16 05:06:33 rt RT: Ticket 1 created in queue 'General' by root
> (/usr/share/request-tracker3.6/lib/RT/Ticket_Overlay.pm:756)#012
> Dec 16 05:06:42 rt RT: About to think about scrips for transaction
> #27#012
> Dec 16 05:06:42 rt RT: About to prepare scrips for transaction #27#012
> Dec 16 05:06:42 rt RT: Found 1 scrips#012
> Dec 16 05:06:42 rt RT: About to commit scrips for transaction #27#012
> Dec 16 05:06:42 rt RT: About to think about scrips for transaction
> #28#012
> Dec 16 05:06:42 rt RT: About to prepare scrips for transaction #28#012
> Dec 16 05:06:42 rt RT: Found 1 scrips#012
> Dec 16 05:06:42 rt RT: About to commit scrips for transaction #28#012
> Dec 16 05:06:42 rt RT: About to think about scrips for transaction
> #29#012
> Dec 16 05:06:42 rt RT: About to prepare scrips for transaction #29#012
> Dec 16 05:06:42 rt RT: Found 1 scrips#012
> Dec 16 05:06:42 rt RT: About to commit scrips for transaction #29#012
> Dec 16 05:06:42 rt RT: About to think about scrips for transaction
> #30#012
> Dec 16 05:06:42 rt RT: About to prepare scrips for transaction #30#012
> Dec 16 05:06:42 rt RT: Found 1 scrips#012
> Dec 16 05:06:42 rt RT: About to commit scrips for transaction #30#012
>
> After reading through the source, I have been unable to find what am I
> missing in my code. Can someone point me in the right direction?
>
> Thanks and best regards.
>
> -lem
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com
>
>   



More information about the rt-users mailing list