[SOLVED] New filters in ITSM Change Overview - howto?

Moderator: crythias

Locked
heeg2au
Znuny newbie
Posts: 39
Joined: 14 Jan 2015, 17:36
Znuny Version: 6.0.27
Real Name: Helmut

[SOLVED] New filters in ITSM Change Overview - howto?

Post by heeg2au »

Hi Guys,
we're running OTRS 3.3.8. for some months now and appreciate the wealth of functionality it provides.
We use the ITSM Change Management module also and it helped us a lot already. One simple change we Need as we processed a lot of changes already would be to extend the filters in the change management overview. E.g., we'd like to see all changes except the closed ones (closed in from our perspective are the ones where status is successful or rejected or retracted or failed or cancelled). Another usage would be to only view changes of certain categories (e.g. only changes of category 'normal'; or all changes except the ones of category 'normal').
Is there any way to achieve this and if so, how?
Any Suggestion is very much appreciated.
Regards,
Helmut
Last edited by heeg2au on 30 Mar 2015, 07:31, edited 1 time in total.
OTRS 6.0.27 (productive)
Extensions: ITSM (SLM, IncidentProblem, Change, Configuration), FAQ, Survey, CMDB Explorer, ImportExport, EscalationPlus
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: New filters in ITSM Change Overview - howto?

Post by RStraub »

The easy way is to edit the SysConfig:
ITSM Change Management -> Frontend::Agent::ViewChangeOverview
There you have a list of states that appear as filters. But that won't be enough for your request, so you probably have to edit the "AgentITSMChange.pm" file.

As an example, you could search for the term $Filters{All} and add after the if clause this filter:

Code: Select all

        $Filters{Test} = {
            Name   => 'Test',
            Prio   => 3000,
            Search => {
                Priorities       => ['3 normal'],
                OrderBy          => \@SortByArray,
                OrderByDirection => \@OrderByArray,
                Limit            => 1000,
                UserID           => $Self->{UserID},
            },
        };
As search parameters you probably can use the format described in the ChangeSearch here:
http://otrs.perl-services.de/docs/ITSMC ... hange.html

Does this help?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
heeg2au
Znuny newbie
Posts: 39
Joined: 14 Jan 2015, 17:36
Znuny Version: 6.0.27
Real Name: Helmut

Re: New filters in ITSM Change Overview - howto?

Post by heeg2au »

Hi there,

first of all: thanks a lot for the fast and great response!
Your hint regarding the search parameters helped me already, however, the filtered column is not visible anymore a soon as the filter is applied. It would be great if the filtered column would be visible again, as we use the categorization in a more detailed definition for governance purposes (e.g. we have 4 normal changes described as 'Normal ①', 'Normal ②' and so on, the numbers in circles representing the business priorities). Additionally, I'm wondering if there's a way to set a specific filter as a default filter for specific agents (ideally preventing them from using other filters).

I also tried to follow your instructions regarding the code you provided. However, my programming skills are very limited :roll: , one might say, the're not even existing. I was able to locate the "AgentITSMChange.pm" file, and was even able to get the Test-Button appear. Unfortunately, the function didn't work so I'd appreciate if you could provide me with a more extensive sample code, including the full if-clause (so I can make sure that I put the code in the correct position including the delimiters. The respechtive section in the "AgentITSMChange.pm" file looks the way shown below (I included a bit more code as I'm not sure, where the relevant Information starts).

Thank you very much for your efforts and best regards,
Helmut

Code: Select all

    # to store the filters
    my %Filters;

    # set other filters based on change state
    if ( $Self->{Config}->{'Filter::ChangeStates'} ) {

        # define position of the filter in the frontend
        my $PrioCounter = 1000;

        # get all change states that should be used as filters
        CHANGE_STATE:
        for my $ChangeState ( @{ $Self->{Config}->{'Filter::ChangeStates'} } ) {

            # do not use empty change states
            next CHANGE_STATE if !$ChangeState;

            # check if state is valid by looking up the state id
            my $ChangeStateID = $Self->{ChangeObject}->ChangeStateLookup(
                ChangeState => $ChangeState,
            );

            # do not use invalid change states
            next CHANGE_STATE if !$ChangeStateID;

            # increase the PrioCounter
            $PrioCounter++;

            # add filter with params for the search method
            $Filters{$ChangeState} = {
                Name   => $ChangeState,
                Prio   => $PrioCounter,
                Search => {
                    ChangeStates     => [$ChangeState],
                    OrderBy          => \@SortByArray,
                    OrderByDirection => \@OrderByArray,
                    Limit            => 1000,
                    UserID           => $Self->{UserID},
                },
            };
        }
    }

    # if only one filter exists
    if ( scalar keys %Filters == 1 ) {

        # get the name of the only filter
        my ($FilterName) = keys %Filters;

        # activate this filter
        $Self->{Filter} = $FilterName;
    }
    else {

        # add default filter, which shows all items
        $Filters{All} = {
            Name   => 'All',
            Prio   => 1000,
            Search => {
                OrderBy          => \@SortByArray,
                OrderByDirection => \@OrderByArray,
                Limit            => 1000,
                UserID           => $Self->{UserID},
            },
        };
    }
OTRS 6.0.27 (productive)
Extensions: ITSM (SLM, IncidentProblem, Change, Configuration), FAQ, Survey, CMDB Explorer, ImportExport, EscalationPlus
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: New filters in ITSM Change Overview - howto?

Post by RStraub »

I just applied my code example and it filters correctly for me. You'd have to put that part right behind your code, so that it looks like this (that's what I meant with after the if clause)

Code: Select all

[.. SNIP ..]

    else {

        # add default filter, which shows all items
        $Filters{All} = {
            Name   => 'All',
            Prio   => 1000,
            Search => {
                OrderBy          => \@SortByArray,
                OrderByDirection => \@OrderByArray,
                Limit            => 1000,
                UserID           => $Self->{UserID},
            },
        };
    }

    $Filters{Test} = {
        Name   => 'Test',
        Prio   => 3000,
        Search => {
            Priorities       => ['3 normal'],
            OrderBy          => \@SortByArray,
            OrderByDirection => \@OrderByArray,
            Limit            => 1000,
            UserID           => $Self->{UserID},
        },
    };
Oh and as hint to keep this file through updates, you should copy this to the custom folder and edit the copy:
cp -p /opt/otrs/Kernel/Modules/AgentITSMChange.pm /opt/otrs/Custom/Kernel/Modules/AgentITSMChange.pm
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
heeg2au
Znuny newbie
Posts: 39
Joined: 14 Jan 2015, 17:36
Znuny Version: 6.0.27
Real Name: Helmut

Re: New filters in ITSM Change Overview - howto?

Post by heeg2au »

Thx again :)
I placed the code to the position you mentioned and the button is there. However, the filter results in the follwing error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.


I assume, it has got to do with the fact, that I need to filter by 'Category' instead of 'Priority'
Would that mean, I need to change the search definition like this?:
Search => {
Categories => ['Normal ②']

I'd like to use Wildcards if possible, so that I can use all categories like 'Normal*' - possible?

And what do you think about the custom search: is it possible to include the filter-column in the result (see my 1st reply)?
OTRS 6.0.27 (productive)
Extensions: ITSM (SLM, IncidentProblem, Change, Configuration), FAQ, Survey, CMDB Explorer, ImportExport, EscalationPlus
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: New filters in ITSM Change Overview - howto?

Post by RStraub »

whoza, so many questions:

1) No, the error does not happen because of the priority. Could you post the apache log while the error occurs? Depending on your OS, you could provide that with:

Code: Select all

tail -f /var/log/apache2/error.log
2) You can use Categories, but not as wildcards. If you follow the API link I gave you, you can see the syntax. That would be for you the IDs or the names:

Code: Select all

       Categories         => [ '1 very low', '2 low' ], #or
       CategoryIDs        => [ 135, 173 ],
3) To show a column in the search result, navigate in the SysConfig to:

Code: Select all

ITSM Change Management -> Frontend::Agent::ViewChangeSearch
In the fourth entry (ShowColumns) set the content of the Category-Key to 1.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
heeg2au
Znuny newbie
Posts: 39
Joined: 14 Jan 2015, 17:36
Znuny Version: 6.0.27
Real Name: Helmut

Re: New filters in ITSM Change Overview - howto?

Post by heeg2au »

Thank you very much, you've solved all my issues!
And again thank you very much for your patience!

The error message in the browser disappeared when I used the IDs (CategoryIDs that is) instead of the names.

Everything works like a charm now and the hint on how to display the search columns was just great!

I realy apreaciate all your fast and competent Support :-D

Best regards,
Helmut
OTRS 6.0.27 (productive)
Extensions: ITSM (SLM, IncidentProblem, Change, Configuration), FAQ, Survey, CMDB Explorer, ImportExport, EscalationPlus
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: New filters in ITSM Change Overview - howto?

Post by RStraub »

Glad I could help, have fun with all the customization, I bet this was just the beginning :)
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Locked