TransactionBatch and TransactionCreate

Hi,

I am trying to use custom scripts in RT3.2.1. I have my custom script
performing the required actions, such as opening ticket, adding an
AdmiCC based of certain criteria, however I cannot send a notification.

I tried to set up different stages, but it looks like TransactionBatch
doesn’t work at all. Even the predefined scripts weren’t executed, when
I changed the stage to TransactionBatch. On TransactionCreate (onCreate
condition) the notification will not be send to AdminCC.

Is there any other way to send notification to an AdminCC just after
adding him/her o a newly created ticket?

Regards,
Michael

It doesn’t work unless you enable $RT::UseTransactionBatch in RT config.

Expected behavior: http://wiki.bestpractical.com/?ScripExecOrder

It doesn’t work as expected unless you don’t apply patch that I sent to
rt-devel.

Current behavior:
If first Transaction in Batch is applicable then scrip would be executed
in other case no. I wrote about all missfeatures. This feature would be
introduced in 3.4 may be with other stages.

Look for more info in rt-devel list.

Michael Bochynski wrote:

It doesn’t work unless you enable $RT::UseTransactionBatch in RT config.

Do I enable it by adding:

Set($UseTransactionBatch, 1);?

Expected behavior: http://wiki.bestpractical.com/?ScripExecOrder

It doesn’t work as expected unless you don’t apply patch that I sent to
rt-devel.

Current behavior:
If first Transaction in Batch is applicable then scrip would be executed
in other case no. I wrote about all missfeatures. This feature would be
introduced in 3.4 may be with other stages.

Look for more info in rt-devel list.

Could you point me to the specific post?
I could find only this one:
http://lists.bestpractical.com/pipermail/rt-devel/2004-May/005766.html

But I am not sure whether it applies to 3.2.1 since the code is
different

Michael

Michael Bochynski wrote:

It doesn’t work unless you enable $RT::UseTransactionBatch in RT config.

Do I enable it by adding:

Set($UseTransactionBatch, 1);?
Yes.

Expected behavior: http://wiki.bestpractical.com/?ScripExecOrder

It doesn’t work as expected unless you don’t apply patch that I sent to
rt-devel.

Current behavior:
If first Transaction in Batch is applicable then scrip would be executed
in other case no. I wrote about all missfeatures. This feature would be
introduced in 3.4 may be with other stages.

Look for more info in rt-devel list.

Could you point me to the specific post?
I could find only this one:
http://lists.bestpractical.com/pipermail/rt-devel/2004-May/005766.html

But I am not sure whether it applies to 3.2.1 since the code is
different
I’m not sure too. I know this applies to 3.0.{7-10}.
Yuo can resolve conflicts. I’m sure that there is not much changes in
3.2 scrip actions handling.

Michael Bochynski wrote:

Expected behavior: http://wiki.bestpractical.com/?ScripExecOrder

It doesn’t work as expected unless you don’t apply patch that I sent to
rt-devel.

I’m sure that there is not much changes in
3.2 scrip actions handling.

Unfortunately there are a lot of code changes. Besides, if I turn the
TransactionBatch in the RT_SiteCofig I still cannot get any script in
this stage to execute.

Is there any other way to automatically add AdminCC and notify them
about a ticket being opened? I don’t want to make them queue watchers,
because they will be added to only certain tickets, based on some
criteria.

Michael

Michael Bochynski wrote:

Michael Bochynski wrote:

Expected behavior: http://wiki.bestpractical.com/?ScripExecOrder

It doesn’t work as expected unless you don’t apply patch that I sent to
rt-devel.

I’m sure that there is not much changes in
3.2 scrip actions handling.

Unfortunately there are a lot of code changes. Besides, if I turn the
TransactionBatch in the RT_SiteCofig I still cannot get any script in
this stage to execute.
Apache restart?

Is there any other way to automatically add AdminCC and notify them
about a ticket being opened? I don’t want to make them queue watchers,
because they will be added to only certain tickets, based on some
criteria.
You don’t need batch stage.

You need custom condition that checks your criteria.
And custom action that adds AdminCC to ticket.

And then you need scrip that notify AdminCC on open event.

http://wiki.bestpractical.com/?WriteCustomAction

And then you need scrip that notify AdminCC on open event.

How do I check for “on open” event?

Michael

Unfortunately there are a lot of code changes. Besides, if I turn
the

TransactionBatch in the RT_SiteCofig I still cannot get any script
in

this stage to execute.
Apache restart?

:slight_smile: not only restart, but also stop->wait->count to ten->start :slight_smile:

Is there any other way to automatically add AdminCC and notify them
about a ticket being opened? I don’t want to make them queue
watchers,

because they will be added to only certain tickets, based on some
criteria.
You don’t need batch stage.

You need custom condition that checks your criteria.
And custom action that adds AdminCC to ticket.

Yeah. Been there, done that. This part works. Custom condition? I use
"On create" condition, and in custom action I check ie subject,
requestor, and add (or not) the particular Admin CC

And then you need scrip that notify AdminCC on open event.

:slight_smile: and this part doesn’t work. I do not want to open ticket i want to
leave it as it is. And “on create” doesn’t send the emails to AdminCC’s

And then you need scrip that notify AdminCC on open event.

How do I check for “on open” event?

Michael

Never mind
(($self->TransactionObj->Field eq ‘Status’) &&
($self->TransactionObj->OldValue eq ‘new’) )

It’s an easy way to check whether the ticket changed from “new” to
something else. Checking for “open” status in my case makes no sense,
since a given ticket may be changed to “open” several times before
resolving.

Thanks anyway,
Michel

Michael Bochynski wrote:

Unfortunately there are a lot of code changes. Besides, if I turn

the

TransactionBatch in the RT_SiteCofig I still cannot get any script

in

this stage to execute.

Apache restart?

:slight_smile: not only restart, but also stop->wait->count to ten->start :slight_smile:
So leave it alone for now. It’s unstable and is there by evil incident :slight_smile:

Is there any other way to automatically add AdminCC and notify them
about a ticket being opened? I don’t want to make them queue

watchers,

because they will be added to only certain tickets, based on some
criteria.

You don’t need batch stage.

You need custom condition that checks your criteria.
And custom action that adds AdminCC to ticket.

Yeah. Been there, done that. This part works. Custom condition? I use
"On create" condition, and in custom action I check ie subject,
requestor, and add (or not) the particular Admin CC

And then you need scrip that notify AdminCC on open event.

:slight_smile: and this part doesn’t work. I do not want to open ticket i want to
leave it as it is. And “on create” doesn’t send the emails to AdminCC’s
:slight_smile: Finaly I got info that I need to help you. Alohhaaa!!!

Your question should be something like this:
I have scrip that notify peoples(including ticket’s AdminCcs) on create.
And also on create I have scrip that adds AdminCC to ticket. RT doesn’t
notify AdminCcs. Why? :slight_smile:

  1. You didn’t read well
    http://wiki.bestpractical.com/index.cgi?ScripExecOrder.

Caveats

 * Triggered scrips prepared without guarantied order.

Nobody guaranty that scrip that notify your admins is executed before
scrip that adds this admins cause event is the same “On Create”.

  1. You can merge this scrips in one.

Move your magic AdminCc assign code to scrip that notify people on
create. But place it in custom condition code. This is required if you
want your AdminCc be in place before any other code(notify) would be
executed.
To preserve meaning of condition “On Create” you should add check:

return 0 unless($self->TransactionObj->Type eq ‘Create’);

			Best regards. Ruslan.

Your question should be something like this:
I have scrip that notify peoples(including ticket’s AdminCcs) on create.
And also on create I have scrip that adds AdminCC to ticket. RT doesn’t
notify AdminCcs. Why? :slight_smile:

  1. You didn’t read well
    http://wiki.bestpractical.com/index.cgi?ScripExecOrder.

I have read it well. So that’s why didn’t ask why the AdminCC is not
notified, because I knew that the script execution is random. Actually,
Notify AdminCcs currently notifies only Queue Watchers. Am I right?

Caveats

 * Triggered scrips prepared without guarantied order.

Nobody guaranty that scrip that notify your admins is executed before
scrip that adds this admins cause event is the same “On Create”.

  1. You can merge this scrips in one.

I finally did it in two scripts :wink:

Move your magic AdminCc assign code to scrip that notify people on
create. But place it in custom condition code. This is required if you
want your AdminCc be in place before any other code(notify) would be
executed.
To preserve meaning of condition “On Create” you should add check:

return 0 unless($self->TransactionObj->Type eq ‘Create’);

I left On Create as it is, in its default configuration. I have another
On Create script with custom action, adding AdminCcs based on certain
criteria (ifs). Then, I have another scrip, with custom condition, which
will be triggered when an AdminCc will be added.

This solution actually is better for me, since it has wider use. The
AdminCc will be notified always, that he/she was added, no matter on the
ticket’s stage. Currently, correct me if I’m wrong, an AdminCc will
receive his first email about a ticket, only if a comment/correspondence
will be added.

I want to notify AdminCc right after adding him, since you do not know
when the first transaction (after adding him/her) will occur.

I personally think that my solution is better :wink: since I killed two
birds with one stone :slight_smile: Maybe it’s worth to be added to next release of
RT as a default script action? :slight_smile:

  		Best regards. Ruslan.

Thanks for your help.
Michael
$self->TicketObj->SetStatus(‘resolved’); :slight_smile:

Michael Bochynski wrote:

Your question should be something like this:
I have scrip that notify peoples(including ticket’s AdminCcs) on create.
And also on create I have scrip that adds AdminCC to ticket. RT doesn’t
notify AdminCcs. Why? :slight_smile:

  1. You didn’t read well
    http://wiki.bestpractical.com/index.cgi?ScripExecOrder.

I have read it well. So that’s why didn’t ask why the AdminCC is not
notified, because I knew that the script execution is random. Actually,
Notify AdminCcs currently notifies only Queue Watchers. Am I right?
No.
From lib/RT/Action/Notify.pm (3.0-MAINT@HEAD)
if ( $arg =~ /\bAdminCc\b/ ) {
push ( @Bcc, $self->TicketObj->AdminCc->MemberEmailAddresses );
push ( @Bcc, $self->TicketObj->QueueObj->AdminCc->MemberEmailAddresses);
}

Caveats

* Triggered scrips prepared without guarantied order.

Nobody guaranty that scrip that notify your admins is executed before
scrip that adds this admins cause event is the same “On Create”.

  1. You can merge this scrips in one.

I finally did it in two scripts :wink:
Cool.

Move your magic AdminCc assign code to scrip that notify people on
create. But place it in custom condition code. This is required if you
want your AdminCc be in place before any other code(notify) would be
executed.
To preserve meaning of condition “On Create” you should add check:

return 0 unless($self->TransactionObj->Type eq ‘Create’);

I left On Create as it is, in its default configuration. I have another
On Create script with custom action, adding AdminCcs based on certain
criteria (ifs). Then, I have another scrip, with custom condition, which
will be triggered when an AdminCc will be added.
This is good solution.

This solution actually is better for me, since it has wider use. The
AdminCc will be notified always, that he/she was added, no matter on the
ticket’s stage.
Good scrip condition. Please add it to wiki.

Currently, correct me if I’m wrong, an AdminCc will
receive his first email about a ticket, only if a comment/correspondence
will be added.
You loose only one transaction when your scrip(that adds AdminCc)
trigger and exactly this transaction also trigger notification. On all
other subsequent transactions your AdminCcs would be on thier places.

I want to notify AdminCc right after adding him, since you do not know
when the first transaction (after adding him/her) will occur.

I personally think that my solution is better :wink: since I killed two
birds with one stone :slight_smile: Maybe it’s worth to be added to next release of
RT as a default script action? :slight_smile:
You can share it and if people find it useful. Then RT someday would
have something that override it functionality and may be add more.

I prefer some ordering on scrips.

This solution actually is better for me, since it has wider use. The
AdminCc will be notified always, that he/she was added, no matter on the
ticket’s stage.
Good scrip condition. Please add it to wiki.

Hmmm… I just found another issue. The script will send an email not
only to the recently-added AdminCc but also to the Queue Watchers …
Any idea how to fix it?

You can share it and if people find it useful.
Sure. I’ll post it. When I remove the previously mentioned bug

Michael

Hi Michael,

Michael Bochynski wrote:

Is there any other way to automatically add AdminCC and notify them
about a ticket being opened? I don’t want to make them queue watchers,
because they will be added to only certain tickets, based on some
criteria.

I just bounced against this. I found that if you add an AdminCC via a
per-queue scrip then the global “Notify AdminCC” scrip ignores it. I’m
not sure why as another global scrip to notify owners when a slip is
assigned to them works fine when the user is assigned via a per-queue
scrip. Weird.

I worked around it by disabling the global “Notify AdminCC” scrip and
creating a per-queue one exactly the same, but just for that queue.
That seems to work as expected. This is in RT 3.2.1, Perl 5.8.4.

Carl.