<br><font size=2 face="sans-serif">I checked the condition code in both
scrips, but they look right to me: they both check field number of the
custom fields.</font>
<br>
<br><font size=2 face="sans-serif">I looked at the Transaction table in
the database and compared a successful case with a wrong one. What I can
see is that for a successful update I only have 2 transaction, while 3
for the wrong case. Instead, it seems that for the good case, there is
one more transaction of type "CustomField" at ticket creation
time. Moreover, the transactions order is different.</font>
<br><font size=2 face="sans-serif">I also noticed that scrips work well
or not depending on the ticket itself, that is, if the scrip is successful
the first time after the ticket creation, then it will never fail afterwords
on the same ticket, and viceversa when it fails the first time.</font>
<br><font size=2 face="sans-serif">In the end, it seems to me that the
problem starts at ticket creation time, and maybe for the transaction execution
timing. I also tried to force a different scrip order (by adding a number
in the scrip name), but it doesn't seem to solve the problem.</font>
<br>
<br><font size=2 face="sans-serif">Any other ideas on this issue?</font>
<br>
<br><font size=2 face="sans-serif">Regards,</font>
<br><font size=2 face="sans-serif">Silvana</font>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Gene LeDuc <gleduc@mail.sdsu.edu></b>
</font>
<p><font size=1 face="sans-serif">19/04/2007 18:24</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Silvana.Giberti@esa.int</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">RT-Users@lists.bestpractical.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [rt-users] Problems with scrips
modifying custom filed  values</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br><font size=3>Hi Silvana,</font>
<br>
<br><font size=3>Since you're suspecting that an extra transaction might
be causing your problem, you probably need to find out what that extra
transaction is.  The easiest way I've found to do this is to go into
your rt3 database and look for the transaction number (from the rt log)
in the Transactions table (I like Toad for accessing mysql from Windows). 
The Type, Field, OldValue, and NewValue fields should get you started. 
Don't be tempted to make any changes, though.</font>
<br>
<br><font size=3>You also might want to double-check that the condition
code in "scrip Y" is producing TRUE only when the first custom
field changes value (not when any custom field changes):</font>
<br><font size=3>  { my $x = 7; return ($self->TransactionObj->Type
eq 'CustomField') && ($self->TransactionObj->Field == $x);
}</font>
<br><font size=3>where $x is the field number for the first custom field.</font>
<br>
<br><font size=3>Good luck!</font>
<br><font size=3>Gene</font>
<br>
<br><font size=3>At 12:19 AM 4/19/2007, Silvana.Giberti@esa.int wrote:</font>
<br><font size=2>I'm having problems with scrips modifying the values of
2 custom fields.</font><font size=3> </font>
<br>
<br><font size=2>The first custom field is created and assigned at ticket
creation (by scrip X), while the second custom field is updated whenever
the first one is modified (by scrip Y), that is after ticket creation and
also everytime the user modifes the first cf.</font><font size=3> </font>
<br>
<br><font size=2>What sometime happens is that scrip Y updates the second
custom field twice, that  is, a first time assigning the new value
and then a second time setting it back to its original value. Sometimes
instead the same scrips work properly on both custom fields, assigning
the right value also to the second one.</font><font size=3> </font>
<br>
<br><font size=2>The same scrips work always well when the custom fields
are first created and assigned the first value.</font><font size=3> </font>
<br>
<br><font size=2>Comparing the 2 cases in RT log file, it looks like there's
an extra transaction firing after the update of the second custom field,
but I can't tell what it does.</font><font size=3> </font>
<br>
<br><font size=2>The function I call to update the custom fields is the
"AddCustomFieldValue", from Record.pm.</font><font size=3> </font>
<br>
<br><font size=2>The custom fields are defined global for tickets in all
queues.</font><font size=3> </font>
<br>
<br><font size=2>(RT 3.6.1, MySQL 4.1.12)</font><font size=3> </font>
<br>
<br><font size=2>Does anyone have an idea of what to do to fix this problem?</font><font size=3>
</font>
<br>
<br><font size=2>Thanks,</font><font size=3> </font>
<br><font size=2>Silvana</font><font size=3> </font>
<br>
<br>
<br><font size=3>-- </font>
<br><font size=3>Gene LeDuc, GSEC</font>
<br><font size=3>Security Analyst</font>
<br><font size=3>San Diego State University</font>
<br>