Drew, Absolutely. We had the same problem awhile back. We changed the "Stage" to TransactionBatch for any scrip that update a field (CF or otherwise) and for scrips that notify using templates that show those fields. Works great.
Kenn LBNL On Wed, Mar 30, 2011 at 11:52 AM, Drew Hahn <[email protected]>wrote: > I must be missing something obvious… > > > > On Create, I have a Scrip that looks at the requestor’s Organization field > (presuming, of course, they’ve sent us email before and we’ve set a value > for it). If it matches one of the values in a multi-select custom field we > have at the Ticket level called “Client”, then it automatically assigns the > “Client” custom field to that ticket. Here is the relevant part from that > Scrip: > > > > my $T_Obj = $self->TicketObj; > > $T_Obj->AddCustomFieldValue( Field => "Client", Value => $client->Name ); > > > > That works great. Next, it goes to another Scrip that then performs a > Notify AdminCcs using a custom template. This template sends the AdminCcs a > copy of the Transaction->Content, but then appends the just assigned custom > field to the email. Here is the relevant part from that Template: > > > > {$Transaction->Content()} > > > > { my $OUTPUT; > > my $rTicket = RT::Ticket->new( $RT::SystemUser ); > > $rTicket->Load($Ticket->id); > > my $values = $rTicket->CustomFieldValues('Client'); > > $OUTPUT .= ":" . $values . ":<BR>"; > > while (my $value = $values->Next ) { > > $OUTPUT .= "*" . $value->Content . "*<BR>"; > > } > > $OUTPUT; > > } > > > > Now, here’s the problem. If that custom field was propagated via the Scrip > mentioned in the first section, it doesn’t carry that value into the > Template even though the Template is executed after it: > > > > Execution Order (reversed): > > Wed Mar 30 14:39:21 2011 The RT System itself - Outgoing email recorded > [Show] > > Wed Mar 30 14:39:20 2011 The RT System itself - Outgoing email recorded > [Show] > > Wed Mar 30 14:39:18 2011 The RT System itself - Client AAAA added > > > > If, however, I use RT to create a new ticket and self-select the Client > custom field, it will work. So, I know I’m pulling the right field out in > the Template. > > > > I even tried re-loading the ticket (as you see above) in the hopes that it > would re-read the new value from the database. > > > > Any idea how I might be able to accomplish this? As far as I can tell, the > Scrip is correctly updating the DB, it executes before the Template gets > rendered, and the code is correct in the Template. Thanks. > > > > --drew > > >
