User Tools

Site Tools

:: Latest version ::



This shows you the differences between two versions of the page.

Link to this comparison view

latest:admin:placeholders [2019/01/09 16:40]
latest:admin:placeholders [2020/04/15 15:23] (current)
Line 1: Line 1:
 +====== Notification placeholders ======
 +The "​Subject"​ and "​Body"​ parts of an email Notification support placeholders:​
 +| Syntax | Example on a **Ticket** notification |
 +| ''​$this<​nowiki>​-></​nowiki>​attribute$''​ | **$this<​nowiki>​-></​nowiki>​ref$** is replaced by the Ticket reference|
 +| ''​$this<​nowiki>​-></​nowiki>​external_key<​nowiki>​-></​nowiki>​attribute$''​ | **$this<​nowiki>​-></​nowiki>​caller_id<​nowiki>​-></​nowiki>​email$** is replaced by the email of the caller of the Ticket |
 +| ''​$this<​nowiki>​-></​nowiki>​representation(attribute)$''​ | **$this<​nowiki>​-></​nowiki>​html(log)$** is replaced by the public log in html format |
 +| ''​$CONSTANT$''​ | **<​nowiki>​$APP_URL$</​nowiki>​** is replaced by the URL of the iTop application |
 +| ''​$this<​nowiki>​-></​nowiki>​function()$''​ | **$this<​nowiki>​-></​nowiki>​hyperlink(portal)$** is replaced by the url to the Ticket on the iTop portal |
 +Those 5 cases are detailed below:
 +//​Additional placeholders can be added by Extensions, such as Approval... ​
 +Check Extension documentation for more details.//
 +===== Attribute placeholders =====
 +^ Function ^ Description ^ Supported types of attributes ^
 +|''​$this<​nowiki>​-></​nowiki>​attribute$''​|The plain text representation of the value of the attribute| any |
 +|''​$this<​nowiki>​-></​nowiki>​id$''​|The id of the current object (there is no such attribute at that time)|
 +|''​$current_contact<​nowiki>​-></​nowiki>​attribute$''​|the person who did the change which activated the trigger|
 +<​note>​**LinkedSet** attributes: the very standard syntax ''​$this<​nowiki>​-></​nowiki>​attribute$''​ returns a list of names separated by a new line character which are replaced by blank in HTML, so use instead ''​$this<​nowiki>​-></​nowiki>​html(functionalcis_list)$''​ to display the bullet list of CIs linked to a User Request.</​note>​
 +<note warning>​Known limitation: Calculated attribute ''​friendlyname''​ is not accurate if one of its underlying field is modified. The workaround is to rebuild the friendlyname within the notification itself.</​note>​
 +===== Extended syntax =====
 +The //extended syntax// provides a quick means to retrieve data from related objects, like in the following examples:
 +  * ''​$<​nowiki>​this->​approver_id->​phone</​nowiki>​$''​
 +  * ''​$<​nowiki>​this->​approver_id->​org_id->​code</​nowiki>​$''​
 +  * ''​$<​nowiki>​this->​approver_id->​org_id->​hyperlink()</​nowiki>​$''​
 +  * ''​$<​nowiki>​this->​parent_request_id->​hyperlink(portal)</​nowiki>​$''​
 +Every built-in functions and attribute representations are available after the last ''<​nowiki>​-></​nowiki>''​).
 +===== Attribute representations =====
 +^ Function ^ Description ^ Supported types of attributes ^
 +|''​$this<​nowiki>​-></​nowiki>​html(attribute)$''​|The HTML representation of the value of the attribute| any |
 +|''​$this<​nowiki>​-></​nowiki>​label(attribute)$''​|The localized representation of the value of the attribute. The language is the language of the user currently logged in. | any (only make sense for AttributeEnum) |
 +|''​$this<​nowiki>​-></​nowiki>​head(attribute)$''​|Plain text of the latest entry in the case log| AttributeCaseLog |
 +|''​$this<​nowiki>​-></​nowiki>​head_html(attribute)$''​|HTML formatted representation of the //latest// entry, whereas ''​$this<​nowiki>​-></​nowiki>​html(attribute)$''​ returns an HTML formatted representation of the //whole// case log (you can apply your own CSS styling to make it beautiful).| AttributeCaseLog |
 +|**New in iTop 2.4**: ''​$this<​nowiki>​-></​nowiki>​raw(attribute)$''​|SQL formatted representation of the date(time), whereas ''​$this<​nowiki>​-></​nowiki>​(attribute)$''​ returns the value formatted regarding the configuration parameter.| AttributeDatetime |
 +===== Fixed placeholders =====
 +^ Placeholder ^ Meaning ^
 +|''​$APP_URL$''​|URL of the iTop application.|
 +|''​$MODULES_URL$''​|Root URL of the modules (e.g. ''​$APP_URL$/​env-production''​).|
 +===== Built-in function placeholders =====
 +^  Placeholder ​ ^  Meaning ​ ^
 +|''​$this<​nowiki>​-></​nowiki>​name()$''​|The name of the current object|
 +|''​$this<​nowiki>​-></​nowiki>​hyperlink()$''​|The url to access the current object in iTop console|
 +|''​$this<​nowiki>​-></​nowiki>​hyperlink(portal)$''​|The url to access the current object in the iTop portal|
 +|''​$this<​nowiki>​-></​nowiki>​hyperlink(itop-portal-view)$''​|To open the current object in iTop portal in read-only mode|
 +|''​$this<​nowiki>​-></​nowiki>​hyperlink(itop-portal-edit)$''​|To open the current object in iTop portal in modification mode|
 +===== Example: UserRequest =====
 +Assuming that a notification is triggered when assigning a User Request, the body of the message could be:
 +Dear $this->​html(agent_id),​
 +The ticket $this->​ref$ has been assigned to you.
 +More information about this ticket
 +Title: $this->​title$
 +Public log:
 +Impacted CIs:
 +Click here to display the details of the ticket: $this->​hyperlink()$ (authentication required)
 +===== Questions & Answers =====
 +**Question: Why my placeholder is not replaced by the real value in the sent email?**\\
 +Answers: ​
 +  - You have made a typo of the field code or that code does not exist on the class which has trigger that notification
 +  - Check the source code of your notification body (CKEditor propose a <​source>​ button), if an html tag is inside the placeholder,​ this breaks the matching mechanism and the text is not replaced by the value.
 +**Question: Can I add automatically a team signature to UserRequest email notification?​**\\
 +  * customize the ''​Team''​ class by adding an ''​signature''​ field, of type ''​AttributeTemplateHTML''​ if you want to make it nice with logo for eg.
 +  * then add ''​$this<​nowiki>​-></​nowiki>​team_id<​nowiki>​-></​nowiki>​signature$''​ at the end of the body
 +**Question: Can I send in my notification the ''​id''​ of the current object?**\\
 +Answer: Though there is no '​id'​ attribute',​ the placeholder ''​$this<​nowiki>​-></​nowiki>​id$''​ is available to represent the iTop internal identifier.
 +**Question: If I have created multiple portals, can I send a hyperlink to a specific portal?**\\
 +Answer: you can point to any portal replacing ''​portal''​ by the ''​id''​ of your new portal. \\
 +Example ''​$this<​nowiki>​-></​nowiki>​hyperlink(partner-portal)$''​