Brent,<br><br><br>Without looking at your code, I can tell you that you should make the stage "TransactionBatch" (be sure to turn that on in your RT_SiteConfig.pm file).<br><br>Try and see if that works.<br><br>Kenn<br>
<br><div class="gmail_quote">On Fri, Dec 2, 2011 at 8:49 AM, Brent Wiese <span dir="ltr"><<a href="mailto:bwiese@elementps.com">bwiese@elementps.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal">I have 4 custom fields in this scenario:<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">1<sup>st</sup> Approval<u></u><u></u></p>
<p class="MsoNormal">2<sup>nd</sup> Approval<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Those are both “Select One Value” dropdowns that apply to tickets. Permissions are “view” for Privileged and modify for a group allowed to approve these tickets.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I have 2 additional fields:<u></u><u></u></p><p class="MsoNormal">1<sup>st</sup> Approved By<u></u><u></u></p><p class="MsoNormal">2<sup>nd</sup> Approved By<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Both are “Enter one value” that apply to tickets. Privileged has view and there are no other permissions set (I don’t want users able to set this field, essentially “read only” - you’ll see why in a minute).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">If an approver makes a selection in one of the select boxes, I have scrip that will enter a value in the corresponding “approved by” field.<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal">Here’s the weird thing – it works perfect for the “1<sup>st</sup>” boxes. But when I choose a value for the 2<sup>nd</sup> approval, it sets it, then reverts it back to the previous value (I’ve tried modifying the field as a superuser to confirm its rolling back and not just deleting the value). The scrip code from the “1<sup>st</sup>” check/set was copy/pasted and only the variables changed to reflect the different column ids.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Here is the snippet from the ticket history:<u></u><u></u></p><p class="MsoNormal"><span>Fri Dec 02 09:35:37 2011</span> <span>Brent Wiese - (CC) 2nd Approval No changed to Yes</span> <u></u><u></u></p>
<p class="MsoNormal"><span>Fri Dec 02 09:35:37 2011</span> <span>The RT System itself - (CC) Seconded By Approved by: Brent Wiese added</span> <u></u><u></u></p><p class="MsoNormal"><a name="133ffb383ee46313_lasttrans"></a><span>Fri Dec 02 09:35:37 2011</span> <span>Brent Wiese - (CC) Seconded By Approved by: Brent Wiese deleted</span> <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Scrip:<u></u><u></u></p><p class="MsoNormal">Condition: User Defined<u></u><u></u></p><p class="MsoNormal">Action: User Defined<u></u><u></u></p><p class="MsoNormal">
Template: Global template: Blank<u></u><u></u></p><p class="MsoNormal">Stage: TransactionCreate<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Custom condition:<u></u><u></u></p><p class="MsoNormal">
unless ($self->TransactionObj->Type eq "CustomField" ) {<u></u><u></u></p><p class="MsoNormal">return 0;<u></u><u></u></p><p class="MsoNormal">}<u></u><u></u></p><p class="MsoNormal">1;<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal">Prep:<u></u><u></u></p><p class="MsoNormal"># Set Field to ID of (CC) 1st Approval:<u></u><u></u></p><p class="MsoNormal">my $CFid = 5;<u></u><u></u></p><p class="MsoNormal"># Set to ID of (CC) 1st Approved By:<u></u><u></u></p>
<p class="MsoNormal">my $CFAppID = 18;<u></u><u></u></p><p class="MsoNormal"># Set Field to ID of (CC) 2nd Approval:<u></u><u></u></p><p class="MsoNormal">my $CFid2 = 17;<u></u><u></u></p><p class="MsoNormal"># Set to ID of (CC) 2nd Approved By:<u></u><u></u></p>
<p class="MsoNormal">my $CFAppID2 = 20;<u></u><u></u></p><p class="MsoNormal"># Set to 1 if you want an extra line that the scrip made changes logged in the ticket history<u></u><u></u></p><p class="MsoNormal">my $rec = 1;<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">my $cf_obj = RT::CustomField->new($RT::SystemUser);<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">my $trans = $self->TransactionObj;<u></u><u></u></p>
<p class="MsoNormal">my $ticket = $self->TicketObj;<u></u><u></u></p><p class="MsoNormal">my $person = $trans->CreatorObj->RealName;<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">if ( $self->TransactionObj->Type eq "CustomField" && $self->TransactionObj->Field == $CFid ) {<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"> $cf_obj->LoadByName( Name => $CFAppID );<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> my $val = $ticket->FirstCustomFieldValue($CFid);<u></u><u></u></p><p class="MsoNormal"> if ($val eq 'Yes') {<u></u><u></u></p>
<p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Approved by: $person", RecordTransaction => $rec );<u></u><u></u></p><p class="MsoNormal">
} elsif ($val eq 'No') {<u></u><u></u></p><p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Disapproved by: $person", RecordTransaction => $rec );<u></u><u></u></p>
<p class="MsoNormal"> } else {<u></u><u></u></p><p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Pending", RecordTransaction => $rec );<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p><p class="MsoNormal">}<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">if ( $self->TransactionObj->Type eq "CustomField" && $self->TransactionObj->Field == $CFid2 ) {<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"> $cf_obj->LoadByName( Name => $CFAppID2 ); <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"> my $val2 = $ticket->FirstCustomFieldValue($CFid2);<u></u><u></u></p>
<p class="MsoNormal"> if ($val2 eq 'Yes') {<u></u><u></u></p><p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Approved by: $person", RecordTransaction => $rec );<u></u><u></u></p>
<p class="MsoNormal"> } elsif ($val2 eq 'No') {<u></u><u></u></p><p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Disapproved by: $person", RecordTransaction => $rec );<u></u><u></u></p>
<p class="MsoNormal"> } else {<u></u><u></u></p><p class="MsoNormal"> $ticket->AddCustomFieldValue(Field => $cf_obj, Value => "Pending", RecordTransaction => $rec );<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p><p class="MsoNormal">}<u></u><u></u></p><p class="MsoNormal">return 1; <span style="font-family:Wingdings">ß</span> I’ve tried return 0 here too and no difference<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">No cleanup.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">It was working this way before I added the $cf_obj variable. I thought maybe hard-coding it to enter the value as RT_System would help, but it made no difference.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I tried doing all the code in the custom condition (which is why I’m still checking if it’s a customfield transaction in the if statement). Works the same either way I try it.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Any thoughts?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks,<u></u><u></u></p><p class="MsoNormal">Brent<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div><br>--------<br>
RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
* Boston — March 5 & 6, 2012<br></blockquote></div><br>