[rt-users] Looping through transactionobj

Brent Wiese bwiese at ElementPS.com
Tue Dec 6 16:41:19 EST 2011


I have a scrip that checks to see if the value of certain customfield value has changed. If so, it sets the value of a different custom field.

I want to expand it to check if the value of another customfield has changed and if so, set the value of a 4th  custom field.

So:
If CF1 changed, set CF2 to "hi"
and/or
If CF3 changed, set CF4 to "bye"

The scrip works fine if either CF1 or CF3 is changed, but if BOTH are changed, it's only setting CF4.

I suspect I'm only catching the highest CF ID number - the last in the set. I have some other CF's on the ticket that have ID's higher than CF1, but lower than CF3 (just the way they got added into the system) and the same thing happens if I change the value of one of them and CF1 - CF2 doesn't get changed, but CF3/CF4 works.

How do I loop through the TransactionObj to make sure I pick up all the changes? I can sort out the non-CF1/3 changes with an IF, but I can't figure out how to get my "while" statement right...

I've tried this:

my $trans = $self->TransactionObj;
while (my $customtrans = $trans->Next){ ... }
and
while (my $customtrans = $trans->Next()){ ... }

But I get:
RT: Scrip 27 Prepare failed: RT::Transaction::Next Unimplemented in RT::Action::UserDefined.

I've tried:
my $cffields = $self->TransactionObj ->CustomField;

Got:
RT: Scrip 27 Prepare failed: RT::Transaction::CustomField Unimplemented in RT::Action::UserDefined.

Tried:
my $cffields = $trans->Field;
while (my $customtrans = $ cffields ->Next()){ ... }

Got:
Scrip 27 Prepare failed: Can't call method "Next" without a package or object reference at (eval 3099) line 24

Thanks,
Brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20111206/fc192408/attachment.htm>


More information about the rt-users mailing list