Problem creating custom dashlet

Moderator: crythias

Locked
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Problem creating custom dashlet

Post by aph »

We have cases where a ticket is ticket is handled by an agent and the solution is implemented. This solution has to be reviewed by his peer and the ticket should be closed. We currently have a dummy user called 'Review' and we set as responsible this user to mark tickets that are to be reviewed.

I would like to create a custom dashlet to show tickets where the logged in agent or the dummy user mentioned above is the responsible.
I stumbled upon this http://blog.otrs.org/2010/09/26/keep-an ... customers/. Although the thread is old, I found it very useful. It mentions
the Dashlets are just a ticket search. If you have a look at the Attributes of the Dashlet “Reminder Tickets” – <Item Key=”Attributes”>TicketPendingTimeOlderMinutes=1;StateType=pending reminder;SortBy=PendingTime;OrderBy=Down; </Item> – you get an impression what could be possible.

It also gives an example of Config.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
 <ConfigItem Name="DashboardBackend###0600-TicketCustomerABC" Required="0" Valid="1">
  <Description Lang="en">Parameters  for the dashboard backend. ...</Description>
  <Description Lang="de">Parameter  für das Dashboard Backend. ...</Description>
  <Group>Ticket</Group>
  <SubGroup>Frontend::Agent::Dashboard</SubGroup>
  <Setting>
   <Hash>
    <Item Key="Module">Kernel::Output::HTML::DashboardTicketGeneric</Item>
    <Item Key="Title">Tickets for Customer ABC</Item>
    <Item Key="Description">All tickets for customer ABC</Item>
    <Item Key="Attributes">CustomerID=foobar.inc;StateType=open;StateType=new;</Item>
    <Item Key="Filter">All</Item>
    <Item Key="Time">Age</Item>
    <Item Key="Limit">10</Item>
    <Item Key="Permission">rw</Item>
    <Item Key="Block">ContentLarge</Item>
    <Item Key="Group">G_CustomerABC</Item>
    <Item Key="Default">1</Item>
    <Item Key="CacheTTLLocal">5</Item>
   </Hash>
  </Setting>
 </ConfigItem>
</otrs_config>
I think I can display the tickets in the custom widget where the logged in agent or the dummy user mentioned above is the responsible, if I select the correct Attributes. How do I go about it? Is there another approach so that I can display tickets marked for review?
Last edited by aph on 27 May 2015, 18:56, edited 2 times in total.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Create custom dashlet

Post by RStraub »

And the question is?

Your link seems to be a tutorial. At least tell us where you are stuck.

Edit: This answer was posted when the original text was only 2 lines long.
Last edited by RStraub on 27 May 2015, 10:11, edited 1 time in total.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

RStraub wrote:And the question is?
The question is which attributes do I enter to display tickets where responsible = logged in agent or dummy user

Edit: I think I had posted the thread before completly formulating it, instead of previewing it as I had intended :D , hence the question from you RStraub
Last edited by aph on 27 May 2015, 10:23, edited 1 time in total.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Create custom dashlet

Post by RStraub »

Try to add to your searchline (Attributes):

Code: Select all

;ResponsibleIDs=[% Env("UserID") %]
EDIT: That is for 4.x syntax, as you are using 3.x it would be:

Code: Select all

;ResponsibleIDs=$Env{"UserID"}
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

RStraub wrote:

Code: Select all

;ResponsibleIDs=$Env{"UserID"}
I suppose that would show tickets of the current user, but how do I display tickets where responsible = "Review"?
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Create custom dashlet

Post by RStraub »

Oh right, then just enter the ID of that user. To find it, either look in the DB, or open up the user in the Admin -> Agent -> "Click on his name" screen and take the ID from the URL.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

I get the error

Code: Select all

Module Kernel::Modules::AgentDashboard not registered in Kernel/Config.pm!
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

Came across this.
viewtopic.php?f=53&t=29235#p118260. As opposed to the question in that thread, I don't want to display the module in menu.
How do I go about it? My Config file is as follows:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
 <ConfigItem Name="DashboardBackend###0600-TicketReview" Required="0" Valid="1">
 <Description Translatable="1">Test</Description>
 <Group>Ticket</Group>
  <SubGroup>Frontend::Agent::Dashboard</SubGroup>
  <Setting>
   <Hash>
    <Item Key="Module">Kernel::Output::HTML::DashboardTicketGeneric</Item>
    <Item Key="Title">Tickets for QS</Item>
    <Item Key="Description">All tickets for Review</Item>
    <Item Key="Attributes">StateType=open;StateType=new;ResponsibleIDs=$Env{"UserID"};ResponsibleIDs=6;</Item>
    <Item Key="Filter">All</Item>
    <Item Key="Time">Age</Item>
    <Item Key="Limit">10</Item>
    <Item Key="Permission">rw</Item>
    <Item Key="Block">ContentLarge</Item>
    <Item Key="Group">G_XXXX</Item>
    <Item Key="Default">1</Item>
    <Item Key="CacheTTLLocal">5</Item>
   </Hash>
  </Setting>
 </ConfigItem>
</otrs_config>
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

I seem to have it working. I placed the file under /opt/otrs/Kernel/Config/Files. I would however like it to work when I place it under /opt/otrs/Custom/Kernel/Config/Files so that the file is not overwritten after an upgrade
Last edited by aph on 27 May 2015, 14:37, edited 1 time in total.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Create custom dashlet

Post by crythias »

Why would it be overwritten? Preface the filename with my. Mycustom1.xml
See also my HowTos for custom dashlet.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

Thanks for the hint crythias.

I have noticed another problem though. The configured options don't seem to work. For example I set

Code: Select all

 <Item Key="Attributes">StateType=pending reminder;OrderBy=Down;ResponsibleIDs=5;ResponsibleIDs=$Env{"UserID"};</Item>
But the dashlet doesn't show the tickets of the responsible user whose ID is 5, but only my tickets under 'my responsibilities'.

EDIT: Using only the parameter ResponsibleIDs=5; I see tickets where I'm responsible under 'My responsibilities' and ticket where of user 5 is responsible under 'All tickets'. I could live with that, if 'All Tickets' showed also the tickets where I'm responsible in addition to tickets of user #5 or I could rename the All Tickets to 'Other Review Tickets' for this dashlet.

My Config is as follows

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="DashboardBackend###0600-TicketReview" Required="0" Valid="1">
        <Description Translatable="1">Test</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Dashboard</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::Output::HTML::DashboardTicketGeneric</Item>
                <Item Key="Title"> Tickets for QS</Item>
                <Item Key="Description">Test</Item>
                <Item Key="Attributes">StateType=pending reminder;OrderBy=Down;ResponsibleIDs=5;ResponsibleIDs=$Env{"UserID"};</Item>
                <Item Key="Time">Age</Item>
                <Item Key="Limit">10</Item>
                <Item Key="Filter"></Item>
                <Item Key="Permission">rw</Item>
                <Item Key="Block">ContentLarge</Item>
                <Item Key="Group">G_LGSEHD_CRM</Item>
                <Item Key="Default">1</Item>
                <Item Key="CacheTTLLocal">0.25</Item>
                <Item Key="DefaultColumns">
                    <Hash>
                        <Item Key="Age">2</Item>
                        <Item Key="Changed">1</Item>
                        <Item Key="CustomerID">1</Item>
                        <Item Key="CustomerName">1</Item>
                        <Item Key="CustomerUserID">1</Item>
                        <Item Key="EscalationResponseTime">1</Item>
                        <Item Key="EscalationSolutionTime">1</Item>
                        <Item Key="EscalationTime">1</Item>
                        <Item Key="EscalationUpdateTime">1</Item>
                        <Item Key="TicketNumber">2</Item>
                        <Item Key="Lock">1</Item>
                        <Item Key="Owner">1</Item>
                        <Item Key="PendingTime">1</Item>
                        <Item Key="Queue">1</Item>
                        <Item Key="Responsible">1</Item>
                        <Item Key="Priority">1</Item>
                        <Item Key="Service">1</Item>
                        <Item Key="State">1</Item>
                        <Item Key="SLA">1</Item>
                        <Item Key="Title">2</Item>
                        <Item Key="Type">1</Item>
                    </Hash>
                </Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
The dashlet looks as follows:
Unbenannt_138.PNG
Furthermore, how do I remove the filters (my locked tickets, my responsibilities, tickets in my queues , all tickets) as the dashlet is supposed to be a single list showing tickets where responsible = user 5 or logged in user
You do not have the required permissions to view the files attached to this post.
Last edited by aph on 27 May 2015, 18:29, edited 3 times in total.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

I realized the 'filters' such as my locked tickets, my responsibilities etc. are derived from /otrs/Kernel/Output/HTML/DashboardTicketGeneric.pm. Thus, I created its copy called MyDashboardTicketGeneric.pm and used it in my config xml instead. I could disable the filter 'tickets in my queues'. How do I disable the filters 'my locked tickets' and 'All Tickets' ?
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Problem creating custom dashlet

Post by aph »

Any ideas how I can hide the filters My locked tickets and All tickets from a dashlet?
Unbenannt_140.PNG
Alternativly, how could I configure the dashlet such that under 'All tickets' the tickets where the dummy user is responsible as well as the tickets where logged in agent is responsible are shown?
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Create custom dashlet

Post by aph »

RStraub wrote:Try to add to your searchline (Attributes):

Code: Select all

;ResponsibleIDs=$Env{"UserID"}
I seem to have narrowed down the problem. It appears that I cannot use a variable ($Env{"UserID"}) in the searchline (Attributes). If I 'hardcode' the responsible IDs it gives me desired result.

Code: Select all

StateType=pending reminder;OrderBy=Down;ResponsibleIDs=5;ResponsibleIDs=2;
In the code above I explicitly mentioned the ID of the dummy user (ID 5) and mine (ID 2). I see tickets where I'm responsible under My responsibilities (1 ticket)
Unbenannt_144.PNG
I see tickets where I'm responsible + tickets where the dummy user is responsible (3 tickets)
Unbenannt_140.PNG
Any pointers as to how I can use the variable $Env{"UserID"} in my searchline?
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Problem creating custom dashlet

Post by aph »

I came a step further. I could hide the filters by commenting out the following code in my custom .pm

Code: Select all

 # get filter ticket counts
    $Self->{LayoutObject}->Block(
        Name => 'ContentLargeTicketGenericFilter',
        Data => {
            %Param,
            %{ $Self->{Config} },
            Name => $Self->{Name},
            %{$Summary},
        },
    );
I'm yet to figure out how I can display ticket responsibilities of the current user + dummy user.
I would appreciate any pointers.

EDIT: Additionally system log shows

Code: Select all

The given param '$Env{"UserID"}' in 'ResponsibleIDs' is invalid!
Invalid integer in query '$Env{"UserID"}'!
Same result with $QEnv
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Problem creating custom dashlet

Post by reneeb »

Please show your code...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Problem creating custom dashlet

Post by aph »

Here is my code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="DashboardBackend###0600-TicketReview" Required="0" Valid="1">
        <Description Translatable="1">Test</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Dashboard</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::Output::HTML::CRMDashboardTicketGeneric</Item>
                <Item Key="Title"> Tickets for Review</Item>
                <Item Key="Description">Test</Item>
                <Item Key="Attributes">StateType=pending reminder;OrderBy=Down;ResponsibleIDs=5;ResponsibleIDs=$Env{"UserID"};</Item>
                <Item Key="Time">Age</Item>
                <Item Key="Limit">10</Item>
                <Item Key="Filter">All</Item>
                <Item Key="Permission">rw</Item>
                <Item Key="Block">ContentLarge</Item>
                <Item Key="Group">G_XXXX</Item>
                <Item Key="Default">1</Item>
                <Item Key="CacheTTLLocal">0.25</Item>
                <Item Key="DefaultColumns">
                    <Hash>
                        <Item Key="Age">2</Item>
                        <Item Key="Changed">1</Item>
                        <Item Key="CustomerID">1</Item>
                        <Item Key="CustomerName">1</Item>
                        <Item Key="CustomerUserID">1</Item>
                        <Item Key="EscalationResponseTime">1</Item>
                        <Item Key="EscalationSolutionTime">1</Item>
                        <Item Key="EscalationTime">1</Item>
                        <Item Key="EscalationUpdateTime">1</Item>
                        <Item Key="TicketNumber">2</Item>
                        <Item Key="Lock">1</Item>
                        <Item Key="Owner">1</Item>
                        <Item Key="PendingTime">1</Item>
                        <Item Key="Queue">1</Item>
                        <Item Key="Responsible">1</Item>
                        <Item Key="Priority">1</Item>
                        <Item Key="Service">1</Item>
                        <Item Key="State">1</Item>
                        <Item Key="SLA">1</Item>
                        <Item Key="Title">2</Item>
                        <Item Key="Type">1</Item>
                    </Hash>
                </Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Problem creating custom dashlet

Post by aph »

Was finally able to solve it. I added following line to my custom pm under my %TicketSearchSummary

Code: Select all

 ResponsibleIDs => [ $Self->{UserID},5 ],
So in conext

Code: Select all

 my %TicketSearchSummary = (
        Locked => {
            OwnerIDs => [ $Self->{UserID}, ],
            Locks => [ 'lock', 'tmp_lock' ],
        },
        Watcher => {
            WatchUserIDs => [ $Self->{UserID}, ],
            Locks        => undef,
        },
        Responsible => {
            ResponsibleIDs => [ $Self->{UserID}, ],
            Locks          => undef,
        },
        MyQueues => {
            QueueIDs => \@MyQueues,
            Locks    => undef,
        },
        All => {
      ResponsibleIDs => [ $Self->{UserID},5 ],
        OwnerIDs => undef,
            Locks    => undef,
        },
I subsequently removed the option ResponsibleIDs=$Env{"UserID"} from the attributes. So my config xml is

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="DashboardBackend###0600-TicketReview" Required="0" Valid="1">
        <Description Translatable="1">Test</Description>
        <Group>Ticket</Group>
        <SubGroup>Frontend::Agent::Dashboard</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::Output::HTML::CRMDashboardTicketGeneric</Item>
                <Item Key="Title"> Tickets for Review</Item>
                <Item Key="Description">Test</Item>
                <Item Key="Attributes">StateType=pending reminder;OrderBy=Down;ResponsibleIDs=5;</Item>
                <Item Key="Time">Age</Item>
                <Item Key="Limit">10</Item>
                <Item Key="Filter">All</Item>
                <Item Key="Permission">rw</Item>
                <Item Key="Block">ContentLarge</Item>
                <Item Key="Group">G_XXXX</Item>
                <Item Key="Default">1</Item>
                <Item Key="CacheTTLLocal">0.25</Item>
                <Item Key="DefaultColumns">
                    <Hash>
                        <Item Key="Age">2</Item>
                        <Item Key="Changed">1</Item>
                        <Item Key="CustomerID">1</Item>
                        <Item Key="CustomerName">1</Item>
                        <Item Key="CustomerUserID">1</Item>
                        <Item Key="EscalationResponseTime">1</Item>
                        <Item Key="EscalationSolutionTime">1</Item>
                        <Item Key="EscalationTime">1</Item>
                        <Item Key="EscalationUpdateTime">1</Item>
                        <Item Key="TicketNumber">2</Item>
                        <Item Key="Lock">1</Item>
                        <Item Key="Owner">1</Item>
                        <Item Key="PendingTime">1</Item>
                        <Item Key="Queue">1</Item>
                        <Item Key="Responsible">1</Item>
                        <Item Key="Priority">1</Item>
                        <Item Key="Service">1</Item>
                        <Item Key="State">1</Item>
                        <Item Key="SLA">1</Item>
                        <Item Key="Title">2</Item>
                        <Item Key="Type">1</Item>
                    </Hash>
                </Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Problem creating custom dashlet

Post by aph »

I was able to configure the dashlet as I wanted. I've opened a new thread for a releated but a different problem I'm facing.viewtopic.php?f=62&t=29291
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
Locked