Scrips with more than one transaction


#1

Hi all,

I want create this scrip:

condition: user defined
action: create tickets
template: my template
stage : transaction create

custom condition: 

    #test if this ticket is now created
    return 0 unless $self->TransactionObj->Type() eq 'Create';

    #test if my cf has value 'work'
    return 0 unless  $self->TicketObj->FirstCustomFieldValue('cf')

eq ‘work’;

    return 1;

       My second test doesn't work because when the transaction type

is create
the value of cf is null (2 diferent transactions).
How can i solve this problem?


#2

Hi all,

       My second test doesn't work because when the transaction type

is create
the value of cf is null (2 diferent transactions).
How can i solve this problem?

Look at “TransactionBatch” parameter in RT_Config.pm


#3

TransactionBatch may be tricky, if you want condition “When CF X is
set to ‘work’ from empty” then you can implement the following pseudo
code:

if ($txn_type eq ‘Create’) {
return 1 if $self->TicketObj->FirstCustomFieldValue(‘cf’) eq 'work’
return 0;
}
if ($txn_type eq ‘CustomField’) {
return 0 unless $txn_field = $cf_id;
return 0 if $txn_old_value; # field had not empty value
return 0 unless $txn_new_value eq ‘work’;
return 1;
}
return 0;On Fri, May 16, 2008 at 5:37 PM, Alexandre de Medeiros Ribeiro alexandre.medeiros@camara.gov.br wrote:

Hi all,

I want create this scrip:

condition: user defined
action: create tickets
template: my template
stage : transaction create

custom condition:

    #test if this ticket is now created
    return 0 unless $self->TransactionObj->Type() eq 'Create';

    #test if my cf has value 'work'
    return 0 unless  $self->TicketObj->FirstCustomFieldValue('cf') eq

‘work’;

    return 1;

=================
My second test doesn’t work because when the transaction type is
create
the value of cf is null (2 diferent transactions).
How can i solve this problem?


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.


#4

Sorry but doesnt work.
What doesn’t work? it is pseudo code and should not work, but should
give you point to move from.

How can i set the TransactionBatch.
read on the wiki

TransactionBatch may be tricky, if you want condition “When CF X is
set to ‘work’ from empty” then you can implement the following pseudo
code:

if ($txn_type eq ‘Create’) {
return 1 if $self->TicketObj->FirstCustomFieldValue(‘cf’) eq 'work’
return 0;
}
if ($txn_type eq ‘CustomField’) {
return 0 unless $txn_field = $cf_id;
return 0 if $txn_old_value; # field had not empty value
return 0 unless $txn_new_value eq ‘work’;
return 1;
}
return 0;

Hi all,

I want create this scrip:

condition: user defined
action: create tickets
template: my template
stage : transaction create

custom condition:

    #test if this ticket is now created
    return 0 unless $self->TransactionObj->Type() eq 'Create';

    #test if my cf has value 'work'
    return 0 unless  $self->TicketObj->FirstCustomFieldValue('cf') eq

‘work’;

    return 1;

=================
My second test doesn’t work because when the transaction type
is
create
the value of cf is null (2 diferent transactions).
How can i solve this problem?


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.


#5

Argh, forgot to add the list back to Ccs :(On Sat, May 17, 2008 at 1:02 AM, Ruslan Zakirov ruz@bestpractical.com wrote:

Want to share it on http://wiki.bestpractical.com/view/CustomConditionSnippets ?

Also, ALWAYS Cc the list, now people don’t know something’s working
and may be somebody is writing you a reply you don’t need anymore.

On Sat, May 17, 2008 at 12:39 AM, Alexandre de Medeiros Ribeiro alexandre.medeiros@camara.gov.br wrote:

tks
it’s working fine.

Em Sáb, 2008-05-17 às 00:05 +0400, Ruslan Zakirov escreveu:

On Fri, May 16, 2008 at 10:05 PM, Alexandre de Medeiros Ribeiro alexandre.medeiros@camara.gov.br wrote:

Sorry but doesnt work.
What doesn’t work? it is pseudo code and should not work, but should
give you point to move from.

How can i set the TransactionBatch.
read on the wiki

Em Sex, 2008-05-16 às 18:41 +0400, Ruslan Zakirov escreveu:

TransactionBatch may be tricky, if you want condition “When CF X is
set to ‘work’ from empty” then you can implement the following pseudo
code:

if ($txn_type eq ‘Create’) {
return 1 if $self->TicketObj->FirstCustomFieldValue(‘cf’) eq 'work’
return 0;
}
if ($txn_type eq ‘CustomField’) {
return 0 unless $txn_field = $cf_id;
return 0 if $txn_old_value; # field had not empty value
return 0 unless $txn_new_value eq ‘work’;
return 1;
}
return 0;

On Fri, May 16, 2008 at 5:37 PM, Alexandre de Medeiros Ribeiro alexandre.medeiros@camara.gov.br wrote:

Hi all,

I want create this scrip:

condition: user defined
action: create tickets
template: my template
stage : transaction create

custom condition:

    #test if this ticket is now created
    return 0 unless $self->TransactionObj->Type() eq 'Create';

    #test if my cf has value 'work'
    return 0 unless  $self->TicketObj->FirstCustomFieldValue('cf') eq

‘work’;

    return 1;

=================
My second test doesn’t work because when the transaction type
is
create
the value of cf is null (2 diferent transactions).
How can i solve this problem?


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


Best regards, Ruslan.

Best regards, Ruslan.