[rt-users] Issue with a Scrip to keep the date of a Owner Changed

Sébastien Mesnard sme at i-tracing.com
Mon Jun 8 05:06:36 EDT 2009


Hello,

 

I try to keep the date of a Owner changed event.

To do this, I use a scrip to write this date value in a CustomField named
"LastOwnerChangeDate".

 

Condition: "On Owner Change"

Action: "User Defined"

Template: "Global Template: Blank"

Stage: "TransactionCreate"

 

Custom condition:

return 1;

 

Custom action preparation code:

my $trans = $self->TransactionObj; 

my $ticket = $self->TicketObj; 

my $cf_obj = RT::CustomField->new($RT::SystemUser); 

my $cf_name = "LastOwnerChangeDate"; 

my $cf_value = $trans->CreatedAsString; 

 

$cf_obj->LoadByName(Name=>$cf_name);

$RT::Logger->debug("Loaded\$cf_obj->Name = ". $cf_obj->Name() ."\n"); 

$ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value,
RecordTransaction=>0); 

return 1;

 

Custom action cleanup code:

return 1;

 

It is almost working... :

- When I steal a ticket it works.

- When I give a ticket from the "People" section it works.

- When I give a ticket from the "Basics"  or "Jumbo" section, the date is
not changed... And here is my issue!

 

In fact, I think that RT begin by evaluating that the owner is changed so
the CustomField "LastOwnerChangeDate" is replaced to the new value by the
scrip (OK, that's good!).

But then RT evaluates the Field "LastOwnerChangeDate" in the web form... RT
see the old value in the field (the new one is already in the DB) and
replace the new value by the old one...

Maybe I’m wrong but this is what I understand from the logs.

 

Logs for "Steal" or "Give" in the "People" section:

Jun  6 13:37:06 rt-support RT: About to think about scrips for transaction
#112

Jun  6 13:37:06 rt-support RT: About to prepare scrips for transaction #112

Jun  6 13:37:06 rt-support RT: Found 1 scrips for TransactionCreate stage
with applicable type(s) Steal

Jun  6 13:37:06 rt-support RT: Loaded$cf_obj->Name = LastOwnerChangeDate

Jun  6 13:37:06 rt-support RT: About to commit scrips for transaction #112

Jun  6 13:37:06 rt-support RT: Committing scrip #12 on txn #112 of ticket #1

Jun  6 13:37:06 rt-support RT: Found 0 scrips for TransactionBatch stage
with applicable type(s) Steal

 

Logs for "Give" in the "Basics"  or "Jumbo" section:

Jun  6 13:36:45 rt-support RT: About to think about scrips for transaction
#110

Jun  6 13:36:45 rt-support RT: About to prepare scrips for transaction #110

Jun  6 13:36:45 rt-support RT: Found 1 scrips for TransactionCreate stage
with applicable type(s) Give

Jun  6 13:36:45 rt-support RT: Loaded$cf_obj->Name = LastOwnerChangeDate

Jun  6 13:36:45 rt-support RT: About to commit scrips for transaction #110

Jun  6 13:36:45 rt-support RT: Committing scrip #12 on txn #110 of ticket #1

Jun  6 13:36:45 rt-support RT: About to think about scrips for transaction
#111

Jun  6 13:36:45 rt-support RT: About to prepare scrips for transaction #111

Jun  6 13:36:45 rt-support RT: Found 1 scrips for TransactionCreate stage
with applicable type(s) CustomField

Jun  6 13:36:45 rt-support RT: About to commit scrips for transaction #111

Jun  6 13:36:45 rt-support RT: Found 0 scrips for TransactionBatch stage
with applicable type(s) Give,CustomField

 

How can I make it works without this issue ?

Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090608/516e29ad/attachment.htm>


More information about the rt-users mailing list