mandatory service in ticket

Moderator: crythias

Post Reply
bahavar
Znuny newbie
Posts: 11
Joined: 14 Mar 2011, 15:49
Znuny Version: 3.0.4

mandatory service in ticket

Post by bahavar »

hi all
in new phone tickets view i want to make filling the service mandatory.
and i want an ajax message thrown when this field is not filled

can anyone tell me how i can to do this .

thanks in advance
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: mandatory service in ticket

Post by MichaelR »

afaik it is not possible to enforce it with the current code.

You will need to change some .pm/.dtl's around

You could always just to one service <-> one customer mapping and make 'PossibleNone' (or what ever its called) activated.

That will select the service by default.
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
bahavar
Znuny newbie
Posts: 11
Joined: 14 Mar 2011, 15:49
Znuny Version: 3.0.4

Re: mandatory service in ticket

Post by bahavar »

thanks for your help
iv already forced it in my code .pm/.dtl file but i was hoping to get some help on creating an ajax message for it.
and could you help me out i cant find
and make 'PossibleNone' (or what ever its called) activated.
field or anything resembling it.

cheers :)
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: mandatory service in ticket

Post by crythias »

you might be able to do it if you get the required css class attached to the field. Render HTML and check To: or another required field.
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
bahavar
Znuny newbie
Posts: 11
Joined: 14 Mar 2011, 15:49
Znuny Version: 3.0.4

Re: mandatory service in ticket [Solved]

Post by bahavar »

Hi,
i was able to solve this issue here's a how to for anyone interested :

first i modified Kernel/Output/HTML/Standard/AgentTicketPhone.dtl and added class="Mandatory" to display a star in front of my service :D
your Service block should look like this
<!-- dtl:block:TicketService -->
<label class="Mandatory" for="ServiceID"><span class="Marker">*</span>$Text{"Service"}:</label>
<div class="Field">
$Data{"ServiceStrg"}
<div id="ServiceIDError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="ServiceIDServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#ServiceID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'TicketFreeText1', 'TicketFreeText2', 'TicketFreeText3', 'TicketFreeText4', 'TicketFreeText5', 'TicketFreeText6', 'TicketFreeText7', 'TicketFreeText8', 'TicketFreeText9', 'TicketFreeText10', 'TicketFreeText11', 'TicketFreeText12', 'TicketFreeText13', 'TicketFreeText14', 'TicketFreeText15', 'TicketFreeText16', 'To', 'Cc', 'Bcc']);
});
//]]></script>
<!--dtl:js_on_document_complete-->
</div>
<div class="Clear"></div>
<!-- dtl:block:TicketService -->



secondly for the ajax part in your phone tickets you must edit Kernel/Modules/AgentTicketPhone.pm
around line 1750 replace the class with the following line:
Class => 'Validate_Required' . ($Param{Errors}->{ServiceIDInvalid} || ' '),

now your build service string should be like this :

# build service string
if ( $Self->{ConfigObject}->Get('Ticket::Service') ) {
$Param{ServiceStrg} = $Self->{LayoutObject}->BuildSelection(
Data => $Param{Services},
Name => 'ServiceID',
Class => 'Validate_Required' . ($Param{Errors}->{ServiceIDInvalid} || ' '),
SelectedID => $Param{ServiceID},
PossibleNone => 1,
TreeView => $TreeView,
Sort => 'TreeView',
Translation => 0,
Max => 200,
);

now you should have the ajax functionality for new phone tickets for email tickets i imagine you should do something similar.

Thanks for your help
srivatsatatti
Znuny newbie
Posts: 85
Joined: 25 Jan 2011, 06:54
Znuny Version: OTRS 3
Company: eStomi Technologies Pvt Ltd
Contact:

Re: mandatory service in ticket

Post by srivatsatatti »

I followed the above steps it worked perfectly. Later i Changed the field name for Service as Number in language (.pm file). But now i am able to save them as optional (although they displayed as required, i can submit the ticket with them as empty). Any idea...
OTRS 3.2.x, Linux Ubuntu, Mysql 5.1.
bahavar
Znuny newbie
Posts: 11
Joined: 14 Mar 2011, 15:49
Znuny Version: 3.0.4

Re: mandatory service in ticket

Post by bahavar »

Hi,
im not sure exactly what you v done but if you changed the name of the service .you should change it in the configuration iv posted as well.
the mandatory part in : <label class="Mandatory" for="ServiceID"><span class="Marker">*</span>$Text{"Service"}:</label>
is what tells the ticket creation page to put a star on the page it dose not do much else :D

perhaps if you could share your changes i could of help

Cheers :D
guillo
Znuny newbie
Posts: 98
Joined: 16 May 2012, 20:05
Znuny Version: 3.0.7

Re: mandatory service in ticket

Post by guillo »

It works like a charm. Thanks!!

I'll try to do the same with the SLA field.
OTRS V 3.0.7 Windows 2008 x64 going for 3.1.7
OTRS 3.1.12 on LINUX UBUNTU SERVER
guillo
Znuny newbie
Posts: 98
Joined: 16 May 2012, 20:05
Znuny Version: 3.0.7

Re: mandatory service in ticket

Post by guillo »

This solution works also for the SLA field but with one weird thing (At least on OTRS 3.1.12)

On the Service block you'll see something like this:

Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'ServiceID', ['NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID'..... etc

As you can see, 'ServiceID' does not appear again between the [ ]

If you want to do the same with SLA field, you will have to add it. You will endup with something like this:

Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'SLAID', ['NewUserID','ServiceID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'SLAID', 'SignKeyID',

Weird indeed.
OTRS V 3.0.7 Windows 2008 x64 going for 3.1.7
OTRS 3.1.12 on LINUX UBUNTU SERVER
jad
Znuny newbie
Posts: 1
Joined: 29 Jul 2013, 12:41
Znuny Version: 3.2.9

Re: mandatory service in ticket

Post by jad »

Hello Guys,

I've tried to do the exact same on CustomerTicketMessage.dtl And CustomerTicketMessage.pm, but it doesn't work for me

-------------CustomerTicketMessage.dtl-------------------

<!-- dtl:block:TicketService -->
<label class="Mandatory" for="ServiceID"><span class="Marker">*</span>$Text{"Service"}:</label>
<div class="Field">
$Data{"ServiceStrg"}
<div id="ServiceIDError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
<div id="ServiceIDServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
$('#ServiceID').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewCustomerTicket'), 'AJAXUpdate', 'ServiceID', ['TypeID', 'Dest', 'PriorityID', 'SLAID', $Data{"DynamicFieldNamesStrg"}]);
});
//]]></script>
<!--dtl:js_on_document_complete-->
</div>
<div class="Clear"></div>
<!-- dtl:block:TicketService -->

------------CustomerTicketMessage.pm------------------

$Param{ServiceStrg} = $Self->{LayoutObject}->BuildSelection(
Data => \%Services,
Name => 'ServiceID',
SelectedID => $Param{ServiceID},
PossibleNone => 1,
TreeView => $TreeView,
Sort => 'TreeView',
Translation => 0,
Max => 200,
Class => "Validate_Required " . ( $Param{Errors}->{ServiceIDInvalid} || '' ),
);
$Self->{LayoutObject}->Block(
Name => 'TicketService',
Data => {
\%Param,
ServiceIDInvalid => $Param{Errors}->{ServiceIDInvalid},
}

);

What am i doing wrong?

Regards,
JAD (*_*)
dorin
Znuny newbie
Posts: 6
Joined: 27 Aug 2013, 10:31
Znuny Version: 3.2.9

Re: mandatory service in ticket

Post by dorin »

Hello Jad,

I need to add the following code to CustomerTicketMessage.pm around line 414:

# check service
if (
$Self->{ConfigObject}->Get('Ticket::Service')
&& !$GetParam{ServiceID}
&& !$IsUpload
&& !$GetParam{Expand}
)
{
$Error{TypeIDInvalid} = 'ServerError';
}
Post Reply