RT6 Create custom widgets in page layout

Hi There!

We recently upgraded to RT6.0.2. When we started we RT, about 16 years ago, we added a custom layout in create/update/display tickets. A layout that simply shows the basic information of the ticket on the left and on the right our own internal plugin to view assets of the company depending on a CF on the left.

Since the upgrade to RT6.0.2 we want to use the RT style layouts as they are made easy to use and maintained (Thanks for that RT dev!).

But we want to keep our internal plugin. Therefore I am trying to get the plugin inside a widget that can be dynamically placed inside the page layout. The whole RT setup is running inside docker and is deployed using CICD.

What we have done:

  • Folder structure:
    ./rt6-ext/local/plugins/RT-Extension-Companion/etc/RT_Config.pm
    –> Variables
    ./rt6-ext/local/plugins/RT-Extension-Companion/lib/ExtWS/Base.pm
    –> Generic API calls
    ./rt6-ext/local/plugins/RT-Extension-Companion/lib/ExtWS/Companion.pm
    –> Specific internal API calls
    ./rt6-ext/local/plugins/RT-Extension-Companion/html/Ticket/Elements/Companion
    –> The part where magic should be happening
    ./rt6-ext/local/plugins/RT-Extension-Companion/lib/RT/Extension/Companion.pm
    –> Extension include

  • RT_SiteConfig.pm
    Plugins: ‘RT::Extension::Companion’
    –> is loaded in the RT System Configuration

  • html/Ticket/Elements/Companion

    <%ARGS>
    $Ticket => undef
    </%ARGS>

    <%INIT>
    my $queue = $Ticket->QueueObj->Id;

    my $cf = RT::CustomField->new($session{‘CurrentUser’});
    $cf->Load(‘license’);

    my $cf_license_id = $cf->Id;
    my $license_name = “Object-RT::Ticket-”.$Ticket->Id.“-CustomField-$cf_license_id-Value”;
    </%INIT>

    <&| /Widgets/TitleBox, title => loc(‘Companion’) &>
    Companion view applet from rt-companion could not be loaded.
    Check the RT configuration and accessibility of the applet.
    </&>

The issue is that the widget is not shown in the available widgets of page layout.
I also tried by adding the next in the site config:
Set(%WebDisplay,
‘RT::Ticket’ => {
‘ShowCompanion’ => {
‘Title’ => ‘Companion’,
‘Component’ => ‘/Ticket/Elements/Companion’,
}
}
);
Set(%WebDisplayRoles,
‘RT::Ticket’ => {
‘Display’ => [ ‘Companion’ ],
},
);

Does anybody know how to add it?
Thanks a lot!

Did you ever git this working? I am having the same problem.

For RT 6 you need to create widgets now, I asked AI to come up with some steps:

Making RT-Extension-Companion Work as an RT6 Widget

Your widget isn’t appearing because RT6 has a different widget system than RT5. The location html/Ticket/Elements/Companion and the %WebDisplay config approach don’t work in RT6.

The Solution

Step 1: Move Your Component to the Correct Location

Old location (doesn’t work in RT6):

html/Ticket/Elements/Companion

New location for RT6:

html/Ticket/Widgets/Display/Companion

Move your component file to: ./rt6-ext/local/plugins/RT-Extension-Companion/html/Ticket/Widgets/Display/Companion

Step 2: Update Your Component

Your component looks mostly correct, but update it slightly for RT6 widgets:

File: html/Ticket/Widgets/Display/Companion

<%ARGS>
$Ticket => undef
</%ARGS>

<%INIT>
# Return early if no ticket
return unless $Ticket && $Ticket->id;

my $queue = $Ticket->QueueObj->Id;

my $cf = RT::CustomField->new($session{'CurrentUser'});
my ($ok, $msg) = $cf->Load('license');

# Return if CF doesn't exist
return unless $ok;

my $cf_license_id = $cf->Id;
my $license_name = "Object-RT::Ticket-".$Ticket->Id."-CustomField-$cf_license_id-Value";
my $license_value = $Ticket->FirstCustomFieldValue('license');
</%INIT>

<div class="widget companion-widget">
  <h3><&|/l&>Companion</&></h3>
  <div class="widget-body">
% if ($license_value) {
    <!-- Your Companion applet goes here -->
    <p>License: <% $license_value %></p>
    <!-- Call your ExtWS::Companion module here -->
% } else {
    <p><&|/l&>Companion view applet from rt-companion could not be loaded.</&></p>
    <p><&|/l&>Check the RT configuration and accessibility of the applet.</&></p>
% }
  </div>
</div>