通知占位符

发送邮件通知的“主题”和“正文”部分支持占位符:

语法工单通知上的示例
Syntax例如在一张通知
$this->attribute$$this->ref$ 是票提述取代
$this->external_key->attribute$$this->caller_id->email$ 取代票的调用者的电子邮件
$this->representation(attribute)$$this->html(log)$ 以html格式取代公共日志
$CONSTANT$$APP_URL$ iTop应用程序的URL替换
$this->function()$$this->hyperlink(portal)$ 取代iTop票门户的url

这5种情况如下:

扩展可以添加其他占位符,例如批准。有关详细信息,请参阅扩展文档。

属性占位符

职能描述支持的属性类型
$this->attribute$属性的价值的纯文本表示形式任何
$this->id$当前对象的ID(当时没有这样的属性) 
$current_contact->attribute$执行变更并激活触发器的人 

链接集属性:非常标准语法$this->attribute$返回用换行符分隔的名称列表,这些名称在HTML中用空格替换,因此请改用$ this-> html(functionalcis_list)$显示项目符号列表配置项链接到用户请求。

已知限制:如果修改了其基础字段之一,则计算得出的属性友好名称不正确。变通方案将在通知自身内部重建友好名称。

扩展的语法

扩展的语法提供了一种从相关对象检索数据的快速方法,如以下示例所示:

  • $this->approver_id->phone$
  • $this->approver_id->org_id->code$ 
  • $this->approver_id->org_id->hyperlink()$ 
  • $ this->父_request_id-> hyperlink(portal)$

每个内置函数和属性表示形式都可以在最后一个->之后使用。

属性表示

职能描述支持的属性类型
$ this-> html(attribute)$属性的价值的HTML表示形式任何
$ this-> label(attribute)$属性的价值的本地化表示。该语言是当前登录的用户的语言。任何(仅对AttributeEnum有意义)
$ this-> head(attribute)$案例日志中最新条目的纯文本属性大小写日志
$ this-> head_html(attribute)$最新条目的HTML格式表示,而$ this-> html(attribute)$返回整个案例日志的HTML格式表示(您可以应用自己的CSS样式以使其美观)。属性大小写日志
iTop 2.4的新功能:$ this-> raw(attribute)$SQL格式表示日期(时间),而$ this->(attribute)$返回有关配置参数格式的价值。属性大小写日志

固定占位符

占位符含义
$APP_URL$iTop应用的URL。
$MODULES_URL$模块的根网址(例如$ APP_URL $$ env-production)。

内置职能占位符

占位符含义
$this->name()$当前对象的名称
$this->hyperlink()$在iTop控制台中访问当前对象的URL
$ this-> hyperlink(portal)$用于访问iTop门户中当前对象的URL
$ this-> hyperlink(itop-portal-view)$以只读模式在iTop门户中打开当前的对象
$ this-> hyperlink(itop-portal-edit)$以修改模式在iTop门户中打开当前的对象

示例:UserRequest

假设分配用户请求时触发了通知,则消息的主体可能是:

Dear $this->html(agent_id),
The ticket $this->ref$ has been assigned to you.

More information about this ticket
Title: $this->title$

Description:
$this->description$

Public log:
$this->head_html(public_log)$

Impacted CIs:
$this->html(functionalcis_list)$

Click here to display the details of the ticket: $this->hyperlink()$ (authentication required)

问题和答案

问题:为什么我的占位符不能被发送的发送邮件中的真实价值代替?
答案:

  1. 您已经对域代码打了错字,或者该代码在具有触发器的类上不存在,该代码为通知
  2. 检查通知主体的源代码(CKEditor提出一个<source>按钮),如果占位符内有一个html标签,这将破坏匹配机制,并且文本不会被价值取代。

问题:是否可以将团队签名自动添加到UserRequest发送邮件通知?
回答:

  • 通过添加类型为AttributeTemplateHTML的签名字段来自定义Team类,如果您想使其带有徽标,例如。
  • 然后在正文末尾添加$ this-> team_id-> signature $

问:我可以在通知中发送当前对象的ID吗?
答案:尽管没有'id'属性',但是占位符$ this-> id $可以用来表示iTop内部标识符。

问题:如果创建了多个门户,是否可以将超链接发送到特定的门户?
答:您可以使用新的门户的ID指向替换门户的任何门户。
示例$ this-> hyperlink(partner-portal)$

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Aadmin%3Aplaceholders


Notification placeholders

The “Subject” and “Body” parts of an email Notification support placeholders:

SyntaxExample on a Ticket notification
$this->attribute$$this->ref$ is replaced by the Ticket reference
$this->external_key->attribute$$this->caller_id->email$ is replaced by the email of the caller of the Ticket
$this->representation(attribute)$$this->html(log)$ is replaced by the public log in html format
$CONSTANT$$APP_URL$ is replaced by the URL of the iTop application
$this->function()$$this->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

FunctionDescriptionSupported types of attributes
$this->attribute$The plain text representation of the value of the attributeany
$this->id$The id of the current object (there is no such attribute at that time) 
$current_contact->attribute$the person who did the change which activated the trigger 

LinkedSet attributes: the very standard syntax $this->attribute$ returns a list of names separated by a new line character which are replaced by blank in HTML, so use instead $this->html(functionalcis_list)$ to display the bullet list of CIs linked to a User Request.

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.

Extended syntax

The extended syntax provides a quick means to retrieve data from related objects, like in the following examples:

  • $this->approver_id->phone$

  • $this->approver_id->org_id->code$

  • $this->approver_id->org_id->hyperlink()$

  • $this->parent_request_id->hyperlink(portal)$

Every built-in functions and attribute representations are available after the last ->).

Attribute representations

FunctionDescriptionSupported types of attributes
$this->html(attribute)$The HTML representation of the value of the attributeany
$this->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->head(attribute)$Plain text of the latest entry in the case logAttributeCaseLog
$this->head_html(attribute)$HTML formatted representation of the latest entry, whereas $this->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->raw(attribute)$SQL formatted representation of the date(time), whereas $this->(attribute)$ returns the value formatted regarding the configuration parameter.AttributeDatetime

Fixed placeholders

PlaceholderMeaning
$APP_URL$URL of the iTop application.
$MODULES_URL$Root URL of the modules (e.g. $APP_URL$/env-production).

Built-in function placeholders

PlaceholderMeaning
$this->name()$The name of the current object
$this->hyperlink()$The url to access the current object in iTop console
$this->hyperlink(portal)$The url to access the current object in the iTop portal
$this->hyperlink(itop-portal-view)$To open the current object in iTop portal in read-only mode
$this->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$

Description:
$this->description$

Public log:
$this->head_html(public_log)$

Impacted CIs:
$this->html(functionalcis_list)$

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:

  1. You have made a typo of the field code or that code does not exist on the class which has trigger that notification

  2. 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?
Answer:

  • 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->team_id->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->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->hyperlink(partner-portal)$

标签:
由 superadmin 在 2020/08/25, 16:20 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司