Add queue change to Update.html (comment/reply)

Hi,

I’ve been trying to create a callback for adding the Queue change field to
tue comment/reply page. (update.html)

In order to do so I’ve been using the existing Extension
“RT::Extension::CustomFieldsOnUpdate” as an example.
Initially to add the Queue field to this extension and to see if it will
eventually work.

Location of the callback files, as far as I could judge this is the only
location where I would need to edit the files:

/opt/rt4/local/plugins/RT-Extension-CustomFieldsOnUpdate/html/Callbacks/CustomFieldsOnUpdate/Ticket/Update.html

The first file I’ve edited was the tile AfterWorked, the bold part is the
thing I’ve added:

*<& /Elements/SelectQueue,

TicketObj => $Ticket,
InTable => 1,
DefaultsFromTopArguments => 0,

&>*
<& /Ticket/Elements/EditCustomFields,
TicketObj => $Ticket,
InTable => 1,
DefaultsFromTopArguments => 0,
&>
<%ARGS>
$Ticket
</%ARGS>

This alone adds the Queue field to the Update.html page. But it doesn’t
show the current value + when changing the value it doesn’t apply this to
the ticket.
So I figured I needed to change the second file, BeforeUpdate, as well. But
this is where I’m stuck, I don’t really have an idea on what to add/how to
add the SelectQueue part to this file. Below the current contents:

<%ARGS>

$TicketObj
$skip_update
$results
$ARGSRef => {}
</%ARGS>
<%INIT>
return unless $ARGSRef->{‘SubmitTicket’};

my $CFs = $TicketObj->CustomFields;
my $ValidCFs = $m->comp(
‘/Elements/ValidateCustomFields’,
CustomFields => $CFs,
NamePrefix => “Object-RT::Ticket-”. $TicketObj->id .“-CustomField-”,
ARGSRef => $ARGSRef
);
unless ( $ValidCFs ) {
$$skip_update = 1;
while (my $CF = $CFs->Next) {
my $msg = $m->notes(‘InvalidField-’ . $CF->Id) or next;
push @$results, loc($CF->Name) . ': ’ . $msg;
}
}
</%INIT>

I take it that I need to make sure that it sets the Queue value and
something like that but compared to the CF code I don’t really see how I
should add the Queue in this.
I’ve tried copying the above CF value, but I can’t seem to get it to work
(keep getting syntax errors). Basically I’m lost in translation on this one
O_o

My goal is to eventually create a specific callback for this, thus not
editing the CustomFieldsOnUpdate extension.
Could someone with a little more experience with Callbacks shed some light
on this? I would expect this to be dead simple, I just don’t yet have a
good grasp on the syntax and the works.

Thanks in advance.

– Bart

Slight update, adding this to the AfterWorked file also shows the current
Queue a ticket belongs to.
Also, changing the queue now works :slight_smile:

<& /Elements/SelectQueue,

Name           => "Queue",
InTable        => 1,
ShowNullOption => 0,
Default        => $Ticket->QueueObj->Id,

&>

Now I just need to figure out how I’m able to add the name of the Queue
dropdown, currently it looks a bit odd. (see screenshot)

Is there a simple option for that in the above syntax?

– BartOp 13 februari 2012 12:34 schreef Bart bart@pleh.info het volgende:

Hi,

I’ve been trying to create a callback for adding the Queue change field to
tue comment/reply page. (update.html)

In order to do so I’ve been using the existing Extension
“RT::Extension::CustomFieldsOnUpdate” as an example.
Initially to add the Queue field to this extension and to see if it will
eventually work.

Location of the callback files, as far as I could judge this is the only
location where I would need to edit the files:

/opt/rt4/local/plugins/RT-Extension-CustomFieldsOnUpdate/html/Callbacks/CustomFieldsOnUpdate/Ticket/Update.html

The first file I’ve edited was the tile AfterWorked, the bold part is the
thing I’ve added:

*<& /Elements/SelectQueue,

TicketObj => $Ticket,
InTable => 1,
DefaultsFromTopArguments => 0,

&>*
<& /Ticket/Elements/EditCustomFields,
TicketObj => $Ticket,
InTable => 1,
DefaultsFromTopArguments => 0,
&>
<%ARGS>
$Ticket
</%ARGS>

This alone adds the Queue field to the Update.html page. But it doesn’t
show the current value + when changing the value it doesn’t apply this to
the ticket.
So I figured I needed to change the second file, BeforeUpdate, as well.
But this is where I’m stuck, I don’t really have an idea on what to add/how
to add the SelectQueue part to this file. Below the current contents:

<%ARGS>

$TicketObj
$skip_update
$results
$ARGSRef => {}
</%ARGS>
<%INIT>
return unless $ARGSRef->{‘SubmitTicket’};

my $CFs = $TicketObj->CustomFields;
my $ValidCFs = $m->comp(
‘/Elements/ValidateCustomFields’,
CustomFields => $CFs,
NamePrefix => “Object-RT::Ticket-”. $TicketObj->id .“-CustomField-”,
ARGSRef => $ARGSRef
);
unless ( $ValidCFs ) {
$$skip_update = 1;
while (my $CF = $CFs->Next) {
my $msg = $m->notes(‘InvalidField-’ . $CF->Id) or next;
push @$results, loc($CF->Name) . ': ’ . $msg;
}
}
</%INIT>

I take it that I need to make sure that it sets the Queue value and
something like that but compared to the CF code I don’t really see how I
should add the Queue in this.
I’ve tried copying the above CF value, but I can’t seem to get it to work
(keep getting syntax errors). Basically I’m lost in translation on this one
O_o

My goal is to eventually create a specific callback for this, thus not
editing the CustomFieldsOnUpdate extension.
Could someone with a little more experience with Callbacks shed some light
on this? I would expect this to be dead simple, I just don’t yet have a
good grasp on the syntax and the works.

Thanks in advance.

– Bart

Slight update, adding this to the AfterWorked file also shows the current
Queue a ticket belongs to.
Also, changing the queue now works :slight_smile:

<& /Elements/SelectQueue,
Name => “Queue”,
InTable => 1,
ShowNullOption => 0,
Default => $Ticket->QueueObj->Id,
&>

Now I just need to figure out how I’m able to add the name of the Queue
dropdown, currently it looks a bit odd. (see screenshot)

Is there a simple option for that in the above syntax?

AfterWorked is probably called inside html

, so you should put
something like:

Best regards, Ruslan.

Queue <& .... &>

Cheers, didn’t know I could use HTML in the AfterWorked file.

Will have a look at the page code (as displayed in the screenshot) and see
if it’s indeed called inside the table.

If so then your snippet would probably do the trick, thanks :slight_smile:

– Bart

Op 13 februari 2012 17:56 schreef Ruslan Zakirov
ruz@bestpractical.comhet volgende:> On Mon, Feb 13, 2012 at 17:45, Bart bart@pleh.info wrote:

Slight update, adding this to the AfterWorked file also shows the current
Queue a ticket belongs to.
Also, changing the queue now works :slight_smile:

<& /Elements/SelectQueue,
Name => “Queue”,
InTable => 1,
ShowNullOption => 0,
Default => $Ticket->QueueObj->Id,
&>

Now I just need to figure out how I’m able to add the name of the Queue
dropdown, currently it looks a bit odd. (see screenshot)

Is there a simple option for that in the above syntax?

AfterWorked is probably called inside html

, so you should put
something like:


Best regards, Ruslan.

Queue <& .... &>

You were right, it did get called inside the table :slight_smile:

I’ve added this code which adopts the proper style:

Queue: > <& /Elements/SelectQueue, > Name => "Queue", > Default => $Ticket->QueueObj->Id, > InTable => 1, > &> >

The screenshot contains the result.

Now to make a seperate plugin out of it :slight_smile: Not sure if I’m able to make
something for the CPAN repository, but I’ll see how far I can get. (first
I’d like to see how this works as a seperate plugin along with to the
CustomFieldsOnUpdate plugin).

– BartOp 13 februari 2012 19:53 schreef Bart bart@pleh.info het volgende:

Cheers, didn’t know I could use HTML in the AfterWorked file.

Will have a look at the page code (as displayed in the screenshot) and see
if it’s indeed called inside the table.

If so then your snippet would probably do the trick, thanks :slight_smile:

– Bart

Op 13 februari 2012 17:56 schreef Ruslan Zakirov ruz@bestpractical.comhet volgende:

On Mon, Feb 13, 2012 at 17:45, Bart bart@pleh.info wrote:

Slight update, adding this to the AfterWorked file also shows the
current
Queue a ticket belongs to.
Also, changing the queue now works :slight_smile:

<& /Elements/SelectQueue,
Name => “Queue”,
InTable => 1,
ShowNullOption => 0,
Default => $Ticket->QueueObj->Id,
&>

Now I just need to figure out how I’m able to add the name of the Queue
dropdown, currently it looks a bit odd. (see screenshot)

Is there a simple option for that in the above syntax?

AfterWorked is probably called inside html

, so you should put
something like:


Best regards, Ruslan.

Queue <& .... &>

Now to make a seperate plugin out of it :slight_smile: Not sure if I’m able to make something for the CPAN
repository, but I’ll see how far I can get. (first I’d like to see how this works as a
seperate plugin along with to the CustomFieldsOnUpdate plugin).

These days, I usually install Dist::Zilla::MintingProfile::RTx and run
dzil -P RTx My-Custom-RT-Module and then put it in source control and
edit away. I realize that may be a slightly higher barrier to entry
than you want, and you can usually get away with judicious renaming /
copying from an existing module. The most common things you’ll need
to touch include lib/RT/Extension/ModuleName.pm (renaming the file and
the package line) and also updating the package line in Makefile.PL.

If you’re familiar with building a normal CPAN extension, the only
real magic in an RT extension is the RTx line in Makefile.PL. If
you’re not familiar with building CPAN extensions, there’s a bit more
framework to wrap your head around.

-kevin

Hi Kevin,

Thanks for the info :slight_smile:

I’ve done some shameless copying of Ruslan’s plugin and created my own out
of it.
Using his plugin as an example was plenty :slight_smile:

It seems that Ruslan’s plugin and this one can work together quite nicely,
you just need to figure out which one you want to load first. In my case I
want the queue change to showup first and then the custom fields. Thus when
you load the plugin make sure that the QueueChangeOnUpdate is listed before
the CustomFieldsOnUpdate plugin in your RT_SiteConfig.pm.

The part that might be difficult for myself a.t.m. is creating an official
plugin out of it and adding it to the Perl repo.
I did however manage to make simple bash script out of it which for now
kinda works for me :slight_smile:

You can check the results in the attatchment.
The script assumes that you have RT installed under /opt/rt4, so if it
isn’t then you may need to edit the paths a little.

I would however like to know how I can add this to Perl, so that it’s a
little more like a normal plugin :slight_smile: (need to find some time to figure out
how to do all of that, I’m not that brilliant with Perl, let alone with
actually adding stuff to the repo)

– Bart

Op 14 februari 2012 17:44 schreef Kevin Falcone
falcone@bestpractical.comhet volgende:> On Tue, Feb 14, 2012 at 07:44:08AM +0100, Bart wrote:

Now to make a seperate plugin out of it :slight_smile: Not sure if I’m able to
make something for the CPAN
repository, but I’ll see how far I can get. (first I’d like to see
how this works as a
seperate plugin along with to the CustomFieldsOnUpdate plugin).

These days, I usually install Dist::Zilla::MintingProfile::RTx and run
dzil -P RTx My-Custom-RT-Module and then put it in source control and
edit away. I realize that may be a slightly higher barrier to entry
than you want, and you can usually get away with judicious renaming /
copying from an existing module. The most common things you’ll need
to touch include lib/RT/Extension/ModuleName.pm (renaming the file and
the package line) and also updating the package line in Makefile.PL.

If you’re familiar with building a normal CPAN extension, the only
real magic in an RT extension is the RTx line in Makefile.PL. If
you’re not familiar with building CPAN extensions, there’s a bit more
framework to wrap your head around.

-kevin


RT Training Sessions (http://bestpractical.com/services/training.html)

  • Boston — March 5 & 6, 2012

RT-Extension-QueueChangeOnUpdate.sh (2.64 KB)

Seems the mailing lists doesn’t really allow .sh files, attempting to
attatch a zip with this mail :stuck_out_tongue:

– BartOp 15 februari 2012 12:18 schreef Bart bart@pleh.info het volgende:

Hi Kevin,

Thanks for the info :slight_smile:

I’ve done some shameless copying of Ruslan’s plugin and created my own out
of it.
Using his plugin as an example was plenty :slight_smile:

It seems that Ruslan’s plugin and this one can work together quite nicely,
you just need to figure out which one you want to load first. In my case I
want the queue change to showup first and then the custom fields. Thus when
you load the plugin make sure that the QueueChangeOnUpdate is listed before
the CustomFieldsOnUpdate plugin in your RT_SiteConfig.pm.

The part that might be difficult for myself a.t.m. is creating an official
plugin out of it and adding it to the Perl repo.
I did however manage to make simple bash script out of it which for now
kinda works for me :slight_smile:

You can check the results in the attatchment.
The script assumes that you have RT installed under /opt/rt4, so if it
isn’t then you may need to edit the paths a little.

I would however like to know how I can add this to Perl, so that it’s a
little more like a normal plugin :slight_smile: (need to find some time to figure out
how to do all of that, I’m not that brilliant with Perl, let alone with
actually adding stuff to the repo)

– Bart

Op 14 februari 2012 17:44 schreef Kevin Falcone <falcone@bestpractical.com

het volgende:

On Tue, Feb 14, 2012 at 07:44:08AM +0100, Bart wrote:

Now to make a seperate plugin out of it :slight_smile: Not sure if I’m able to
make something for the CPAN
repository, but I’ll see how far I can get. (first I’d like to see
how this works as a
seperate plugin along with to the CustomFieldsOnUpdate plugin).

These days, I usually install Dist::Zilla::MintingProfile::RTx and run
dzil -P RTx My-Custom-RT-Module and then put it in source control and
edit away. I realize that may be a slightly higher barrier to entry
than you want, and you can usually get away with judicious renaming /
copying from an existing module. The most common things you’ll need
to touch include lib/RT/Extension/ModuleName.pm (renaming the file and
the package line) and also updating the package line in Makefile.PL.

If you’re familiar with building a normal CPAN extension, the only
real magic in an RT extension is the RTx line in Makefile.PL. If
you’re not familiar with building CPAN extensions, there’s a bit more
framework to wrap your head around.

-kevin


RT Training Sessions (http://bestpractical.com/services/training.html)

  • Boston — March 5 & 6, 2012

RT-Extension-QueueChangeOnUpdate.sh.zip (1.17 KB)

_<

Didn’t know this:

mBlox Email Attachment Policy:

Emails containing batch, executable or script attachments (even within a
zip compressed file) are NOT permitted through the mBlox messaging
network.

Below a link to my wiki where you can easilly download the actual script,
seems that’s the best way for now :wink:

– BartOp 15 februari 2012 12:23 schreef Bart bart@pleh.info het volgende:

Seems the mailing lists doesn’t really allow .sh files, attempting to
attatch a zip with this mail :stuck_out_tongue:

– Bart

Op 15 februari 2012 12:18 schreef Bart bart@pleh.info het volgende:

Hi Kevin,

Thanks for the info :slight_smile:

I’ve done some shameless copying of Ruslan’s plugin and created my own
out of it.
Using his plugin as an example was plenty :slight_smile:

It seems that Ruslan’s plugin and this one can work together quite
nicely, you just need to figure out which one you want to load first. In my
case I want the queue change to showup first and then the custom fields.
Thus when you load the plugin make sure that the QueueChangeOnUpdate is
listed before the CustomFieldsOnUpdate plugin in your RT_SiteConfig.pm.

The part that might be difficult for myself a.t.m. is creating an
official plugin out of it and adding it to the Perl repo.
I did however manage to make simple bash script out of it which for now
kinda works for me :slight_smile:

You can check the results in the attatchment.
The script assumes that you have RT installed under /opt/rt4, so if it
isn’t then you may need to edit the paths a little.

I would however like to know how I can add this to Perl, so that it’s a
little more like a normal plugin :slight_smile: (need to find some time to figure out
how to do all of that, I’m not that brilliant with Perl, let alone with
actually adding stuff to the repo)

– Bart

Op 14 februari 2012 17:44 schreef Kevin Falcone <
falcone@bestpractical.com> het volgende:

On Tue, Feb 14, 2012 at 07:44:08AM +0100, Bart wrote:

Now to make a seperate plugin out of it :slight_smile: Not sure if I’m able to
make something for the CPAN
repository, but I’ll see how far I can get. (first I’d like to see
how this works as a
seperate plugin along with to the CustomFieldsOnUpdate plugin).

These days, I usually install Dist::Zilla::MintingProfile::RTx and run
dzil -P RTx My-Custom-RT-Module and then put it in source control and
edit away. I realize that may be a slightly higher barrier to entry
than you want, and you can usually get away with judicious renaming /
copying from an existing module. The most common things you’ll need
to touch include lib/RT/Extension/ModuleName.pm (renaming the file and
the package line) and also updating the package line in Makefile.PL.

If you’re familiar with building a normal CPAN extension, the only
real magic in an RT extension is the RTx line in Makefile.PL. If
you’re not familiar with building CPAN extensions, there’s a bit more
framework to wrap your head around.

-kevin


RT Training Sessions (http://bestpractical.com/services/training.html)

  • Boston — March 5 & 6, 2012