You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2010-11-17 18:06:26

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Email Template Question

I need some help with some syntax with the email templates.  I am trying to make a template that will, when a certain category is selected, reply with a specific message.  And, if its not that category, send a normal ticket template.

To do this, I tried this with an IF ELSE END statement:

##IFticket.category='Category Name'##
[Message to receive if ticket category = 'Category Name']
 ##ENDIFticket.category##
 ##ELSEticket.category##
##IFticket.storestatus=solved##
##lang.ticket.url## : ##ticket.urlapprove##  
##lang.ticket.autoclosewarning##
##lang.ticket.solvedate## : ##ticket.solvedate##
##lang.ticket.solution.type## : ##ticket.solution.type##
##lang.ticket.solution.description## : ##ticket.solution.description## ##ENDIFticket.storestatus##
##ELSEticket.storestatus## ##lang.ticket.url## : ##ticket.url## ##ENDELSEticket.storestatus##
##lang.ticket.description##

##lang.ticket.title## :##ticket.title##
##lang.ticket.author.name## :##IFticket.author.name## ##ticket.author.name## ##ENDIFticket.author.name## ##ELSEticket.author.name##--##ENDELSEticket.author.name##
##lang.ticket.creationdate## :##ticket.creationdate##
##lang.ticket.closedate## :##ticket.closedate##
##lang.ticket.requesttype## :##ticket.requesttype##
##IFticket.itemtype## ##lang.ticket.item.name## : ##ticket.itemtype## - ##ticket.item.name## ##IFticket.item.model## - ##ticket.item.model## ##ENDIFticket.item.model## ##IFticket.item.serial## -##ticket.item.serial## ##ENDIFticket.item.serial##  ##IFticket.item.otherserial## -##ticket.item.otherserial## ##ENDIFticket.item.otherserial## ##ENDIFticket.itemtype##
##IFticket.assigntouser## ##lang.ticket.assigntouser## : ##ticket.assigntouser## ##ENDIFticket.assigntouser##
##lang.ticket.status##  : ##ticket.status##
##IFticket.assigntogroup## ##lang.ticket.assigntogroup## : ##ticket.assigntogroup## ##ENDIFticket.assigntogroup##
##lang.ticket.urgency## : ##ticket.urgency##
##lang.ticket.impact## : ##ticket.impact##
##lang.ticket.priority## : ##ticket.priority##
##IFticket.user.email## ##lang.ticket.user.email## : ##ticket.user.email ##ENDIFticket.user.email##
##IFticket.category####lang.ticket.category##  :##ticket.category## ##ENDIFticket.category## ##ELSEticket.category## ##lang.ticket.nocategoryassigned## ##ENDELSEticket.category##
##lang.ticket.content## : ##ticket.content##


##IFticket.storestatus=closed##
##lang.ticket.solvedate## : ##ticket.solvedate##
##lang.ticket.solution.type## : ##ticket.solution.type##
##lang.ticket.solution.description## : ##ticket.solution.description##
##ENDIFticket.storestatus##


##lang.ticket.numberoffollowups## : ##ticket.numberoffollowups##

##FOREACH LAST followups##

[##followup.date##] ##lang.followup.isprivate## : ##followup.isprivate##
##lang.followup.author## ##followup.author##
##lang.followup.description## ##followup.description##
##lang.followup.date## ##followup.date##

##ENDFOREACHfollowups##
##lang.ticket.numberoftasks## : ##ticket.numberoftasks##

##FOREACHtasks##

[##task.date##] ##lang.task.isprivate## : ##task.isprivate##
##lang.task.author## ##task.author##
##lang.task.description## ##task.description##
##lang.task.time## ##task.time##
##lang.task.category## ##task.category##

##ENDFOREACHtasks##

##ENDELSEticket.category##

When I created a test ticket with that category, though, I got

##IFticket.category='Category Name'##
 [Message to receive if ticket category = 'Category Name']
 ##ENDIFticket.category##
  
Description : OMG BULL!

 
Already done followup(s) : 0
Task(s) already done : 0
##ENDELSEticket.category##

Then, if I didn't set any category (which will happen most of the other times), I got something slightly different, with what seems to be an error about there being "No defined category".

 ##IFticket.category='Category Name'##
[Message to receive if ticket category = 'Category Name']
 ##ENDIFticket.category##
 
Web Link : http://helpdesk/index.php?redirect=ticket_779 
Description of the ticket
Name :TEST OTHER STUFF 
Requester : Sean Tapscott 
Opening date :2010-11-17 10:39 
Closing date : 
Request source :Simplified interface


Status  : New

Urgency : Medium
Impact : Medium
Priority : Medium 

##ELSEticket.category## No defined category 
Description : TEST OTHER STUFF

 
Already done followup(s) : 0
Task(s) already done : 0
##ENDELSEticket.category##

Any suggestions on how to create the correct syntax?

Last edited by sean.tapscott (2010-11-17 18:12:56)


Now using 0.78.1 on CentOS.

Offline

#2 2010-11-18 16:09:17

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

I'm going to have to bump this, it is important, and I think it would be good information for the community to have since documentation on the email template tags is scarce.


Now using 0.78.1 on CentOS.

Offline

#3 2010-11-19 16:07:01

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Bump again.  How many bumps does it take till you get to the center of the lollipop?  What is the syntax of the Email Templates and their if statements?  Maybe they only support tags that already have possible values?  If so, its not very clear.


Now using 0.78.1 on CentOS.

Offline

#4 2010-11-22 16:10:46

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Bump once again.


Now using 0.78.1 on CentOS.

Offline

#5 2010-11-22 17:01:53

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Email Template Question

To compare, you must only use 1 word not protected by '
So, verify the name of your category (you can use _ if you need).

##IFticket.category= Category_Name##
   ...blablabla...
##ENDIFticket.category##


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#6 2010-11-22 19:36:27

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

So, it seems to have correctly filtered out the IF section when the category doesn't match the name, but when I then changed the category to the matching one and tried again, it still filtered out the section that evaluates to true.

 ##IFticket.category=Category_Name##
         Text section that should display when expression = true.
 ##ENDIFticket.category##
 ##ELSEticket.category## 
 ##IFticket.storestatus=solved## 
 ##lang.ticket.url## : ##ticket.urlapprove##   
 ##lang.ticket.autoclosewarning## 
 ##lang.ticket.solvedate## : ##ticket.solvedate##
 ##lang.ticket.solution.type## : ##ticket.solution.type##
 ##lang.ticket.solution.description## : ##ticket.solution.description## ##ENDIFticket.storestatus## 
 ##ELSEticket.storestatus## ##lang.ticket.url## : ##ticket.url## ##ENDELSEticket.storestatus## 
 ##lang.ticket.description## 

 ##lang.ticket.title##  :##ticket.title## 
 ##lang.ticket.author.name##  :##IFticket.author.name## ##ticket.author.name## ##ENDIFticket.author.name## ##ELSEticket.author.name##--##ENDELSEticket.author.name## 
 ##lang.ticket.creationdate##  :##ticket.creationdate## 
 ##lang.ticket.closedate##  :##ticket.closedate## 
 ##lang.ticket.requesttype##  :##ticket.requesttype##
 ##IFticket.itemtype## ##lang.ticket.item.name##  : ##ticket.itemtype## - ##ticket.item.name## ##IFticket.item.model## - ##ticket.item.model## ##ENDIFticket.item.model## ##IFticket.item.serial## -##ticket.item.serial## ##ENDIFticket.item.serial##  ##IFticket.item.otherserial## -##ticket.item.otherserial## ##ENDIFticket.item.otherserial## ##ENDIFticket.itemtype## 
 ##IFticket.assigntouser## ##lang.ticket.assigntouser##  : ##ticket.assigntouser## ##ENDIFticket.assigntouser##
 ##lang.ticket.status##  : ##ticket.status##
 ##IFticket.assigntogroup## ##lang.ticket.assigntogroup##  : ##ticket.assigntogroup## ##ENDIFticket.assigntogroup##
 ##lang.ticket.urgency##  : ##ticket.urgency##
 ##lang.ticket.impact##  : ##ticket.impact##
 ##lang.ticket.priority##  : ##ticket.priority## 
 ##IFticket.user.email## ##lang.ticket.user.email##  : ##ticket.user.email ##ENDIFticket.user.email## 
 ##IFticket.category## ##lang.ticket.category##  :##ticket.category## ##ENDIFticket.category## ##ELSEticket.category## ##lang.ticket.nocategoryassigned## ##ENDELSEticket.category## 
 ##lang.ticket.content##  : ##ticket.content## 


##IFticket.storestatus=closed##
 ##lang.ticket.solvedate## : ##ticket.solvedate##
 ##lang.ticket.solution.type## : ##ticket.solution.type##
 ##lang.ticket.solution.description## : ##ticket.solution.description##
##ENDIFticket.storestatus## 

  
 ##lang.ticket.numberoffollowups## : ##ticket.numberoffollowups## 

##FOREACH LAST followups## 
 
 [##followup.date##] ##lang.followup.isprivate## : ##followup.isprivate## 
 ##lang.followup.author## ##followup.author##
 ##lang.followup.description## ##followup.description##
 ##lang.followup.date## ##followup.date## 

##ENDFOREACHfollowups## 
 ##lang.ticket.numberoftasks## : ##ticket.numberoftasks## 

##FOREACHtasks## 
 
 [##task.date##] ##lang.task.isprivate## : ##task.isprivate## 
 ##lang.task.author## ##task.author##
 ##lang.task.description## ##task.description##
 ##lang.task.time## ##task.time##
 ##lang.task.category## ##task.category## 

##ENDFOREACHtasks## 

##ENDELSEticket.category##

I thought I got the If Else Endif syntax right, but it creates a strange result still.

 
 
Web Link : http://helpdesk/index.php?redirect=ticket_799 
Description of the ticket
Name :Test Email Template 
Requester : Sean Tapscott 
Opening date :2010-11-22 11:11 
Closing date : 
Request source :Simplified interface


Status  : New

Urgency : Medium
Impact : Medium
Priority : Medium 

Category (class)  :Category_Name

Now using 0.78.1 on CentOS.

Offline

#7 2010-11-23 14:45:34

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Email Template Question

What's the name of the category you want to filter ?


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#8 2010-11-23 16:06:14

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

"American Muscle Website Down", of course no quotes.  I put American_Muscle_Website_Down .  Think its too long?


Now using 0.78.1 on CentOS.

Offline

#9 2010-11-23 16:23:42

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Email Template Question

You must change the name of your category to American_Muscle_Website_Down and it'll be ok


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

#10 2010-11-23 17:17:40

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Is this by design, or do you think you might improve this later?  I like having spaces in my categories or it starts looking unprofessional.

And it did work.  Didn't like my endelse statement at the end, but as long as that message is at the top there.

Last edited by sean.tapscott (2010-11-23 17:29:30)


Now using 0.78.1 on CentOS.

Offline

#11 2010-11-23 20:51:58

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Still some weird activity with this template.  Have you tried something similar?  If the category matches, I do get the message at the top, but it also includes other sections of the template.  The syntax I used should remove all texts if that certain category matches, right? 

Then, if the category doesn't match, we should skip to the ##ELSEticket.category## section and continue as normal, I thought.  Instead, it corrupts the ##ticket.urlapprove## tag so it no longer functions.  Could someone test this template to see if it works for them?


Now using 0.78.1 on CentOS.

Offline

#12 2010-11-26 17:26:51

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

I'm going to continue to bump this until we can figure out why the above template causes such weird things to happen.  Right now, it seems as though the template tagging system is either buggy, unfinished, or too undocumented to make any sense.

The else statements don't seem to make any sense either, or they don't work.  Is there any french documentation on the template tags?  I'd happily google translate it into speakable english if it existed.


Now using 0.78.1 on CentOS.

Offline

#13 2010-11-26 18:58:30

remi
GLPI-DEV
From: Champagne
Registered: 2007-04-28
Posts: 7,127
Website

Re: Email Template Question

> template tagging system is either buggy
Patch welcome

> unfinished
Patch also welcom

> or too undocumented
Contribution to documentation welcom

+


Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/

Offline

#14 2010-11-26 19:52:57

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Discovered the else problem.  In the template, there was another occurrence of ##ENDELSEticket.category## which caused my else statement to disappear prematurely. 

Still doesn't explain why the weblink is resolving to "http://notificationtemplatetranslation. … ticket_813" instead of just "http:/helpdesk/index.php?redirect=ticket_813".


Now using 0.78.1 on CentOS.

Offline

#15 2010-11-26 19:57:23

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Managed to fix the URL problem, apparently both of the hyperlinks in the HTML section of the notification got distorted.  I had only been looking at the first, but I needed to fix the second URL in the default notification as well.


Now using 0.78.1 on CentOS.

Offline

#16 2010-12-07 13:09:26

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: Email Template Question

move to bug section for study


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

#17 2010-12-07 14:16:46

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: Email Template Question

For name comparison I think this is not the good solution.
If the category name change your will have troubles.
I add a ticket to be discussed : https://forge.indepnet.net/issues/2513

Maybe adding informations of category ID may be more useful.

Actually it is not possible to cascade conditions. That's why you have troubles I think.


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

#18 2010-12-07 16:32:17

sean.tapscott
Member
Registered: 2010-06-16
Posts: 303

Re: Email Template Question

Yeah, Moyo, I had to remove that other category if section to make it work.  Still not sure why any of the changes corrupted the HTML links, but at least I was able to fix it by going in and editing the link in the HTML version of the template.


Now using 0.78.1 on CentOS.

Offline

#19 2010-12-14 18:56:00

MoYo
GLPI - Lead
From: Poitiers
Registered: 2004-09-13
Posts: 14,513
Website

Re: Email Template Question

For name comparison you could try this :
https://forge.indepnet.net/projects/glp … ions/13316


MoYo - Julien Dombre - Association INDEPNET
Contribute to GLPI :    Support     Contribute     References     Freshmeat

Offline

Board footer

Powered by FluxBB