Re: [rt-users] Looping through transactionobj

2011-12-07 Thread Bart
Wouldn't it be enough to have this set of commands?

If CF1 changed, set CF2 to “hi”

If CF3 changed, set CF4 to “bye”

Without the and/or in between, a scrip is sequential so it will just run
from top to bottom.

-- Bart


Op 6 december 2011 22:41 schreef Brent Wiese bwi...@elementps.com het
volgende:

 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

 
 RT Training Sessions (http://bestpractical.com/services/training.html)
 * Boston — March 5  6, 2012


RT Training Sessions (http://bestpractical.com/services/training.html)
* Boston — March 5  6, 2012

[rt-users] Looping through transactionobj

2011-12-06 Thread Brent Wiese
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

RT Training Sessions (http://bestpractical.com/services/training.html)
* Boston — March 5  6, 2012