WorkOrderAgent name added to printed ChangeOverview

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

RStraub
OTRS guru
Posts: 2050
Joined: 13 Mar 2014, 09:16
OTRS Version?: 5.0.14
Real Name: Rolf Straub

WorkOrderAgent name added to printed ChangeOverview

Postby RStraub » 13 Nov 2014, 12:33

We wanted to add the name of the assigned WorkOrderAgent to the printed (PDF) view of a Change.
For this, edit the AgentITSMChangePrint.pm as follows:

1) Add the 'WorkOrderAgent' to the table header:
Original ->

Code: Select all

            # add table header
            $Table{CellData}[ $Row++ ] = [
                { Font => 'ProportionalBold', Content => '#', },
                { Font => 'ProportionalBold', Content => $Translation->Get('Title'), },
                { Font => 'ProportionalBold', Content => $Translation->Get('State'), },
                {
                    Font    => 'ProportionalBold',
                    Content => $Translation->Get('PlannedStartTime'),
                },
---- SNIP ----

Edited version ->

Code: Select all

            # add table header
            $Table{CellData}[ $Row++ ] = [
                { Font => 'ProportionalBold', Content => '#', },
                { Font => 'ProportionalBold', Content => $Translation->Get('Title'), },
                { Font => 'ProportionalBold', Content => $Translation->Get('State'), },
                {
                    Font    => 'ProportionalBold',
                    Content => $Translation->Get('WorkOrderAgent'),
                },
                {
                    Font    => 'ProportionalBold',
                    Content => $Translation->Get('PlannedStartTime'),
                },
---- SNIP ----


2) Edit the width of the columns:
Original ->

Code: Select all

            $Table{ColumnData}[0]{Width} = 2;
            $Table{ColumnData}[1]{Width} = 63;
            $Table{ColumnData}[2]{Width} = 25;
            $Table{ColumnData}[3]{Width} = 40;
            $Table{ColumnData}[4]{Width} = 40;
            $Table{ColumnData}[5]{Width} = 40;
            $Table{ColumnData}[6]{Width} = 40;

Edited version ->

Code: Select all

            $Table{ColumnData}[0]{Width} = 2;
            $Table{ColumnData}[1]{Width} = 63;
            $Table{ColumnData}[2]{Width} = 25;
            $Table{ColumnData}[3]{Width} = 30;
            $Table{ColumnData}[4]{Width} = 30;
            $Table{ColumnData}[5]{Width} = 30;
            $Table{ColumnData}[6]{Width} = 30;
            $Table{ColumnData}[7]{Width} = 30;


3) Query and push UserName; Search for the loop

Code: Select all

        for my $WorkOrderID ( @{ $Change->{WorkOrderIDs} } ) {


Query the name inside of the loop:

Code: Select all

            my $Current_WO_Agent_Name = $Self->{UserObject}->UserName(
                UserID => $WorkOrder->{WorkOrderAgentID},
            );


And add the variable to the Array-Push:
Original ->

Code: Select all

            push @WorkOrderOverview,
                [
                $WorkOrder->{WorkOrderNumber},
                $WorkOrder->{WorkOrderTitle},
                $WorkOrder->{WorkOrderState},
                $WorkOrder->{PlannedStartTime},
                $WorkOrder->{PlannedEndTime},
                $WorkOrder->{ActualStartTime},
                $WorkOrder->{ActualEndTime},
                ];

Edited version ->

Code: Select all

            push @WorkOrderOverview,
                [
                $WorkOrder->{WorkOrderNumber},
                $WorkOrder->{WorkOrderTitle},
                $WorkOrder->{WorkOrderState},
                $Current_WO_Agent_Name,
                $WorkOrder->{PlannedStartTime},
                $WorkOrder->{PlannedEndTime},
                $WorkOrder->{ActualStartTime},
                $WorkOrder->{ActualEndTime},
                ];


And voila, printing the Change Overview now returns the assigned WorkOrderAgent name.

PS: As this is my first "How-To" and edit to the .pm files, any tips are welcome. Especially since there appear log-errors (Need User or UserID) if no Agent is assigned.
Currently using: OTRS 5.0.14 -- MariaDB -- Ubuntu 16 LTS

Return to “Howtos”

Who is online

Users browsing this forum: No registered users and 1 guest