create different templates according to types

English! place to talk about development, programming and coding
Post Reply
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

create different templates according to types

Post by nicole19890107 »

Hello community,
I changed the some parts of TickedPhone, such adding new DynamicField, moving some parts up and changed names.
Image
Now I have a question, as the picture shows, can I select different templates according to different type.
For example, there are several types: CAF, NOC::General, NOC::Outage, NOC::Maintenance, can I select the template for General by choose the type: General. Because there're some different parts among pages for them.
Thank you.
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

Is someone there?
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: create different templates according to types

Post by crythias »

Use a variation on this: viewtopic.php?f=60&t=8032
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
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

Hi, I checked the link and changed codes according to it, but it didn't work: there's nothing happened when I selected the queue to "Junk".
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: create different templates according to types

Post by crythias »

nicole19890107 wrote:Hi, I checked the link and changed codes according to it, but it didn't work: there's nothing happened when I selected the queue to "Junk".
OK, then it's doing exactly what you told it to do... (My crystal ball is a little cloudy :) )

Care to share your dtl?
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
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

this is the default what i told it to do:
Image
but when i choose queue to "junk", it still shows:
Image
and codes i added in CustomeTicketMessage.dtl:

Code: Select all

 //above two lines are already there
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('ServiceID').style.display = 'none';
    break;
    default:
      document.compose.RichText.value = "Default"; //remove this. debug only. shows queue information
      
    }
// the following two lines are the existing last two lines of CustomerTicketMessage.dtl 
when i choose junk, nothing happened, i dont know if there's something wrong with switch.
Thank you
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

hi crythias, do you need to see other codes?
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: create different templates according to types

Post by crythias »

nicole19890107 wrote:hi crythias, do you need to see other codes?
Actually, I needed a better question asked: "When I change queue to Junk, it doesn't change the body. How do I fix that?"
viewtopic.php?f=60&t=8032&start=50#p81987

Code: Select all

CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' ); 
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
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

hi, the problem is not only about body, but some codes like

Code: Select all

document.getElementById('ServiceID').style.display = 'none';document.getElementById('SLAD').style.display = 'block';
don't work, i cannot let them dont display
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: create different templates according to types

Post by crythias »

View source on the rendered document and check spelling of getElementById params. SLAD may not work, for instance, but SLAID might?
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
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

hi crythias, in my codes it is SLAID, I'm sorry for made a mistake here, actually i feel the wrong part is about the switch. I test the part

Code: Select all

document.getElementById('SLAID').style.display = 'none';
      document.getElementById('ServiceID').style.display = 'none';
they work when i write the codes belong to "default" like this

Code: Select all

default:
      document.compose.RichText.value = "Default"; //remove this. debug only. shows queue information
      document.getElementById('SLAID').style.display = 'none';
      document.getElementById('ServiceID').style.display = 'none';
However, when i write them for switch nothing happened, these are all of my codes

Code: Select all

<script type="text/javascript">
    Core.Customer.InitFocus();
//above two lines are already there
    switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
    case  "3\|\|Junk": // need to slash escape the pipes
      document.compose.RichText.value = "This is junk<br/>and line 2"; // only if you want to change the body. destroys user input if queue changes
      document.getElementById('SLAID').style.display = 'none';
    //  document.getElementById('LabelTicketFreeText1').style.display = 'block';
    break;
    default:
      document.compose.RichText.value = "Default"; //remove this. debug only. shows queue information
      document.getElementById('SLAID').style.display = 'none';
      document.getElementById('ServiceID').style.display = 'none';
      //document.getElementById('LabelTicketFreeText1').style.display = 'none';
    }
// the following two lines are the existing last two lines of CustomerTicketMessage.dtl 
</script>
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: create different templates according to types

Post by crythias »

Nicole, can you please explain the result you're attempting to achieve?

Note that you can't get a service until you select a customer.
You can't get an SLA until you choose a Service

Let's say you want to make a change based upon change dest/queue:

Code: Select all

<label class="Mandatory" for="Dest"><span class="Marker">*</span> $Text{"To queue"}:</label>
                    <div class="Field">
                        $Data{"ToStrg"}
                        <div id="DestError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
                        <div id="DestServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
function nonetext() {
   document.compose.Subject.value = ""; //clear the subject
   CKEDITOR.instances.RichText.setData( '' ); // clear the body
   $('#DynamicField_dummy').parent().addClass( 'Hidden' ); // Hide anything related to the "dummy" DynamicField
   $('#DynamicField_dummy').removeClass( 'Mandatory' ); //don't make the hidden field mandatory
}
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
    switch (document.getElementById('Dest').value) {
    case  "4\|\|Misc": // need to slash escape the pipes
      nonetext();
      $('#DynamicField_dummy').parent().removeClass( 'Hidden' ); //unhide
      $('#DynamicField_dummy').addClass( 'Mandatory' ); // make it mandatory
      CKEDITOR.instances.RichText.setData( '<p>This is Line1</p><p>This is Line2</p>' );
   break;

    default:
      nonetext();
}
    });
//]]></script>
<!--dtl:js_on_document_complete-->
(gathered more from Page 2)
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
nicole19890107
Znuny newbie
Posts: 31
Joined: 24 Jun 2013, 22:30
Znuny Version: 3.2.6

Re: create different templates according to types

Post by nicole19890107 »

hello crythias,
thank you for your help, problem solved :)
Post Reply