[SOLVED] Next State as Mandatory Field

Moderator: crythias

Locked
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

[SOLVED] Next State as Mandatory Field

Post by rafaqf »

How can I do the "Next State" field as Mandatory (like the Body or a mandatory TicketFreeText) in the Customer interface? Or at least you have to choose a state,
not leaving it as '-'.

I can't see the option to change it anywhere.

Thanks a lot.
Last edited by rafaqf on 13 Dec 2012, 18:19, edited 1 time in total.
OTRS 3.0.11 and KIX4OTRS on Linux
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Next State as Mandatory Field

Post by crythias »

How is this beneficial?
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

crythias wrote:How is this beneficial?
It's not a matter of benefit, it's a request from our customer.
OTRS 3.0.11 and KIX4OTRS on Linux
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Next State as Mandatory Field

Post by crythias »

I don't see how this is going to be anything but annoying, unless every action changes a state, plus you won't have any clue what the previous state is. nonetheless, add class="Mandatory" everywhere.

Likely candidates:
AdminITSMStateMachine.dtl: <label for="StateID">$Text{"State"}:</label>
AdminNotificationEvent.dtl: <label for="StateID">$Text{"State"}: </label>
AgentFAQAdd.dtl: <label for="StateID">$Text{"State"}:</label>
AgentFAQEdit.dtl: <label for="StateID">$Text{"State"}:</label>
AgentTicketBulk.dtl: <label for="StateID">$Text{"Next state"}:</label>
AgentTicketCompose.dtl: <label for="StateID">$Text{"Next ticket state"}:</label>
CustomerTicketZoom.dtl: <label for="StateID">$Text{"Next state"}:</label> $Data{"NextStatesStrg"}
AgentTicketActionCommon.dtl: <label for="NewStateID">$Text{"Next state"}:</label>
AgentTicketBulk.dtl: <label for="StateID">$Text{"Next state"}:</label>

Code: Select all

<label class="Mandatory" for="StateID"><span class="Marker">*</span> $Text{"Next ticket state"}:</label>
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

crythias wrote:I don't see how this is going to be anything but annoying, unless every action changes a state, plus you won't have any clue what the previous state is. nonetheless, add class="Mandatory" everywhere.
Thank you so much.

I know that shouldn't be like that because the system is like it is; the customer even doesn't know what happens if they don't change the state, because they believe they have to, that's just in the possible case that they do. I'm just a worker, with project managers on me, I will test it tomorrow, if it's so bad of course I will explain it.

Actually, can you explain with more detail why it is so bad? If it is possible to update articles and the ticket without changing the state, why the mandatory class is so annoying?

Thanks again.
OTRS 3.0.11 and KIX4OTRS on Linux
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Next State as Mandatory Field

Post by jojo »

why the customer should change state everytime he goes into the system? Also per default there should not be a - in next state.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Next State as Mandatory Field

Post by crythias »

rafaqf wrote:can you explain with more detail why it is so bad?
General work flow:
Click the button relative to the task (move/respond/whatever)
do that task. maybe add a note.
If you have the option to next state, the default state is the previous state, though it doesn't show up as the highlighted state. It doesn't change the state if you don't change it.

Why is bad to make it mandatory?
Well, now you have to choose a state for every action that shows a next state. This is prone to error, as you could change it to a state you don't want/isn't the previous state. You have to choose "something". By default you don't have to think about it unless you *want* to choose something.
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

crythias wrote:
rafaqf wrote:can you explain with more detail why it is so bad?
General work flow:
Click the button relative to the task (move/respond/whatever)
do that task. maybe add a note.
If you have the option to next state, the default state is the previous state, though it doesn't show up as the highlighted state. It doesn't change the state if you don't change it.
Anyway, with the class Mandatory I still can submit without changing the state.

The state '-' comes from KIX4OTRS, it modifies the perl code thus some behaviours are different, and that's also maybe what makes the mandatory class not working for the "Next State".

I've re-written the code like the original one (I guess!):

Code: Select all

        if ( $Self->{Config}->{State} ) {
            # set state
            my %NextStateData = $Self->{StateObject}->StateGet( ID => $GetParam{StateID} );
            my $NextState = $NextStateData{Name}
                || $Self->{Config}->{StateDefault}
                || 'open';
            $Self->{TicketObject}->StateSet(
                TicketID  => $Self->{TicketID},
                ArticleID => $ArticleID,
                State     => $NextState,
                UserID    => $Self->{ConfigObject}->Get('CustomerPanelUserID'),
            );
        }
but nothing happens. Is that snippet the right one for the CustomerTicketZoom.pm?

Thanks a lot.
OTRS 3.0.11 and KIX4OTRS on Linux
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: Next State as Mandatory Field

Post by reneeb »

The DropDown needs the additional class "Validate_Required"...
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

reneeb wrote:The DropDown needs the additional class "Validate_Required"...
Like that?

Code: Select all

<!-- dtl:block:FollowUpState -->
                        <div>
                            <label for="StateID" class="Mandatory"><span class="Marker">* </span>$Text{"Next State"}:</label> 
                            <div class="Validate_Required">$Data{"NextStatesStrg"}</div>
                        </div>
<!-- dtl:block:FollowUpState -->
OTRS 3.0.11 and KIX4OTRS on Linux
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

Ok, I think I found where is the problem:

Code: Select all

        # build next states string
        if ( $Self->{Config}->{State} ) {
            my %NextStates = $Self->{TicketObject}->TicketStateList(
                TicketID       => $Self->{TicketID},
                Action         => $Self->{Action},
                CustomerUserID => $Self->{UserID},
            );
            my %StateSelected;
            if ( $Param{StateID} ) {
                $StateSelected{SelectedID} = $Param{StateID};
            }
            else {

                # KIX4OTRS-capeIT
                # preselect current ticket state, if no default state configured
                #$StateSelected{SelectedValue} = $Self->{Config}->{StateDefault};
                $StateSelected{SelectedValue} = $Self->{Config}->{StateDefault}
                    || $InitialSelected{State}
                    || '';

                # EO KIX4OTRS-capeIT
            }

            # KIX4OTRS-capeIT
            # default state can be disabled (offers empty selection)
            if ( !$Self->{Config}->{StateDefault} ) {
                $NextStates{''} = '-';
            }

            # EO KIX4OTRS-capeIT

            $Param{NextStatesStrg} = $Self->{LayoutObject}->BuildSelection(
                Data => \%NextStates,
                Name => 'StateID',
                %StateSelected,
            );
            $Self->{LayoutObject}->Block(
                Name => 'FollowUpState',
                Data => \%Param,
            );
        }
OTRS 3.0.11 and KIX4OTRS on Linux
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: Next State as Mandatory Field

Post by reneeb »

There should be a "BuildSelection" call a few lines later. There you can add CSS-classes...
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

Re: Next State as Mandatory Field

Post by rafaqf »

reneeb wrote:There should be a "BuildSelection" call a few lines later. There you can add CSS-classes...
Is not that? Or you mean a explicit function definition?

Code: Select all

$Param{NextStatesStrg} = $Self->{LayoutObject}->BuildSelection(
          Data => \%NextStates,
          Name => 'StateID',
          %StateSelected,
);
OTRS 3.0.11 and KIX4OTRS on Linux
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: Next State as Mandatory Field

Post by reneeb »

It's exactly that code snippet. Replace it with

Code: Select all

    $Param{NextStatesStrg} = $Self->{LayoutObject}->BuildSelection(
              Data => \%NextStates,
              Name => 'StateID',
              Class => 'Validate_Required',
              %StateSelected,
    );
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
rafaqf
Znuny newbie
Posts: 80
Joined: 30 Mar 2011, 11:10
Znuny Version: 3

[SOLVED] Next State as Mandatory Field

Post by rafaqf »

reneeb wrote:It's exactly that code snippet. Replace it with

Code: Select all

    $Param{NextStatesStrg} = $Self->{LayoutObject}->BuildSelection(
              Data => \%NextStates,
              Name => 'StateID',
              Class => 'Validate_Required',
              %StateSelected,
    );
Thanks a lot, that's it :)
OTRS 3.0.11 and KIX4OTRS on Linux
Locked