请求表单定制

名称:请求表单定制

描述:根据服务目录定义个性化的请求表单。为给定类型的请求添加额外的字段。

版本:2.1.2

发布:2020-03-27

itop-version-min:2.3.2

码:combodo定制请求表

状态:稳定

备用名称:请求模板

扩散:iTop集线器

如果您在此扩展程序的2.1.0之前从升级获得升级,请检查升级流程

该组件的其他版本:1.0.5 

特征

该模块提供了能力,以便在用户请求上动态添加其他字段,以便更好地对其进行限定。根据所选的服务服务子目录,建议的其他字段将有所不同。

例如,当用户要求“新的虚拟机”时,我们可能希望他在结构化字段中提供CPU的数量,RAM的数量和OS的类型,而不希望用户自己提供它们。描述字段。

您只需要定义模板,然后在用户创建工单时,其他字段将基于所选的工单子目录出现在工单版本表单中。

请求模板与服务子目录相关。请求模板可以向用户请求添加一个或多个其他字段。其他字段可以是以下类型:

  • 日期和日期时间
  • 字符串(如果需要,使用常规表达式格式化)
  • 文字区
  • CSV清单
  • 基于OQL查询的列表
  • 持续时间
  • 只读隐藏字段

修订记录

发布日期版本注释
2020-03-262.1.1-修正使用转换表单提交时的回归
-修复了删除对象上的TemplateFieldValue的问题
2019-12-042.1.0-现在可以查询请求模板字段
-修复了请求模板视图上缺少的菜单
-更新DE翻译
2019-01-302.0.14修复2.0.10中引入的回归:自定义日期格式不再起作用
2018-12-192.0.13-修复了DoCheckToWrite失败时屏幕上弹出的不必要的错误消息的问题
-修正执行通知(检查数组是否存在)
-更新西班牙语翻译(感谢Miguel Turrubiates!)
2018-06-272.0.12添加DE翻译
2018-06-262.0.11ES + BR翻译,默认搜索属性
2018-01-262.0.10工单字段现在可以定制形式使用。
还修复了2个在通知模板($service_details $)中使用的错误:
-N1079,当用户离开未定义时,则在发送邮件中显示为错误消息:“自定义字段错误:格式错误:缺少template_data”;
-N°1080当字段旨在选择对象时,发送邮件主体会显示所选对象的ID。
2018-01-052.0.9自定义表单现在与事件兼容
2017-11-132.0.8现在,在通知之前的UserRequest创建中记录了service_details
2017-09-082.0.7创建对象时未在通知中设置请求模板价值
2017-03-012.0.6添加了模块设置,以在更改为包含具有相同代码的字段的其他模板时重置模板字段价值
2016-12-132.0.5修复了与原有门户连接使用时的问题。需要iTop> 2.3.2才能使date/time选择器正常工作
2016-11-292.0.4已实现的占位符(例如$ this-> html(service_details)$。需要iTop> 2.3.1才能使占位符正常工作。
2016-09-082.0.3在日期和日期时间字段中添加了验证模式。修复了手动启动cron时的PHP警告。
2016-09-022.0.2现在,隐藏字段和只读字段就像多行字符串一样呈现(就像文本区域一样,尽管它是只读的)-请注意,这在iTop 2.3.0+的控制台中可以正常工作,但是需要iTop> 2.3.1才能使用增强客户门户中增强功能的优势(原有门户中没有变更!)
2016-08-032.0.1支持控制台和增强客户门户(均需要iTop 2.3.0,否则行为与1.0.5相同)
2015-11-261.0.5修复了从门户提交带有包含一些特殊字符的ENUM字段的模板的工单时崩溃的问题。
2015-09-291.0.4修复了当“下拉列表”字段在值列表的开头包含一些奇怪的字符(重音符号,问号...)时导致崩溃的问题。
2014-12-101.0.3化妆品上的模块名称。
2014-04-031.0.2轻度修复,允许非管理员用户访问CSV中的导入模板字段。
2014-03-101.0.1与对象的属性同名的模板字段的错误修复。
2014-02-051.0.0最早的版本,未经验证。

局限性

占位符不适用于iTop 2.3.1和更早版本。

安装和升级

使用标准安装流程 对于此扩展。

级:为了能够对确实在请求模板中设置了特定价值的旧用户请求进行搜索处理,iTop管理员需要运行一次特殊页面,该页面会将每个(用户请求)模板用户分解到新表中,因此可以用OQL查询。

php populateTemplateFieldValue.php --append

您可以使用“ --append”或“ --reset”,结果相同,执行时间可能不同。

  • --reset从头开始重新计算
  • --append仅爆炸尚未爆炸的模板数据

配置

可以在iTop配置文件的itop-request-template部分中调整以下设置:

参数类型描述默认价值
copy_to_log模板值应复制到的属性中。设置为空字符串以禁用此行为。公众_log

可以在iTop配置文件的模板库部分中调整以下设置:

参数类型描述默认价值
hidden_​​fields_profiles简档(角色)的CSV列表。如果用户具有列出的简档中的ANY,则她将看不到“ hidden”类型的字段。门户用户
reset_fields_on_template_change布尔值如果设置为“ true”,则更改模板时将重置价值字段,即使某些字段具有相同的代码。
view_extra_数据

FIXME

 

关系

用法

创建请求模板

从服务管理菜单中,单击“请求模板”:

https://www.itophub.io/wiki/media?w=200&tok=23c619&media=extensions%3Aitop-request-template-menu.png

这些页面显示了已定义的请求模板的列表。单击按钮“新建”以创建一个新的:

https://www.itophub.io/wiki/media?w=300&tok=cd18b3&media=extensions%3Aitop-request-template-new.png

请求模板以其名称标识为相关的服务和服务子服务。

如果为给定的服务子类别定义了多个模板,则在门户上使用该标签选择模板。

选项卡“字段”用于定义模板的字段:

https://www.itophub.io/wiki/media?w=800&tok=b80b46&media=extensions%3Aitop-request-template-list-field.png

单击“创建新字段”以定义一个新字段:

https://www.itophub.io/wiki/media?w=300&tok=c4b80b&media=extensions%3Aitop-request-template-create-field.png

这是属性的完整说明:

属性描述
唯一标识符,可在另一个字段中定义的查询中使用。此价值必须由字母数字字符组成,并且不能以数字开头模型
订购一个整数,用于定义字段在表单中的显示顺序3
标签用户看到的标签,提示输入价值设备模型
强制性的用户是否必须输入选择价值
输入类型…参见上文的详细说明清单
值(OQL或CSV)用于下拉列表仅用于定义此元素的允许值列表。这可以是逗号分隔的值列表(例如“高,中,低”)。 OQL在表单:template-> code中可以有一个参数,其中code是另一个字段的代码。它还可以使用占位符,例如::current_contact->org_id or :this->org_id ,它们引用工单的客户。SELECT模型WHERE brand_id = :template->brand
初始价值用于为文本或文本区域字段设置初始价值y
格式允许您定义常规表达式来验证文本字段^[a-zA-Z]$

在CSV中提供“值”时:将所有值写在一行中,不带回车符

在OQL中提供“值”时:不要在OQL查询中使用friendlyname。

限于...在格式中使用此正则表达式
一个发送邮件[a-zA-Z0-9._&'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}
电话号码^\+?[0-9\ ]{8,20}$
一个网址
https?,ftp)\://([a-zA-Z0-9+!*(),;?&=\$_.-]+(\:[a-zA-Z0-9+!*(),;?&=\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\:[0-9]{2,5})?(/([a-zA-Z0-9%+\$_-]\.?)+)*/?(\?[a-zA-Z+&\$_.-][a-zA-Z0-9;:[\]@&%=+/\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\$_.-]*)?

输入类型可以具有以下值之一:

输入类型描述
日期纯日期,由日历的平均值输入,或直接输入
日期和时间日期和时间,通过日历的平均值输入,或直接输入
下拉列表属性值定义的列表
持续时间时间流逝
终端用户(客户门户)无法看到的价值,但处理人员(控制台)可以看到。价值由价值的初始价值设置
清单价值可以在建议值列表中进行选择。这些值由属性值的平均值定义…
只读初始价值中定义的价值,任何人都无法修改
文本一行文字,可以通过设置格式来强制使用该格式
文字区多行文字

“预览”选项卡显示模板的预览,因为它将在控制台中显示:

https://www.itophub.io/wiki/media?w=300&tok=883cbf&media=extensions%3Aitop-request-template-preview.png

客户门户上的行为

如果终端用户在客户门户上选择了与请求模板相关的服务子类别,则会显示此模板的特定字段,并在名称服务详细信息下分组。

https://www.itophub.io/wiki/media?w=500&tok=2335d0&media=extensions%3Aitop-request-template-portal-enhanced.png

创建用户请求时,此附加信息将复制到外部留言中:

https://www.itophub.io/wiki/media?media=extensions%3Aitop-request-template-public-log-enhanced.png

支持人员也可以从控制台查看或编辑用户请求详细信息中的信息:

https://www.itophub.io/wiki/media?w=500&tok=ae4406&media=extensions%3Aitop-request-template-console.png

模板占位符

在通知模板或可使用模板的其他任何位置,以下占位符将可用。

假设这是一个UserRequest:

  • $ this->service_details $:所选值的纯文本表示。这适用于纯文本发送邮件。尽管似乎可以在HTML文档中使用它,但是通过使用PRE标签,不建议这样做,因为HTML实体(如<)仍然需要转义。
  • $ this-> html(service_details)$:所选值的HTML表示形式。

隐藏字段被强制从占位符中排除。

当模板价值对应于在iTop中选择的对象时,返回的价值将是对象的友好名称。

问题和答案

问题:我可以获取没有关联请求模板的UserRequest吗?
答:是&否。

像这样的查询将失败

SELECT UserRequest WHERE ISNULL(service_details) = 1

尽管这样的查询可以工作,但是如果您在使用服务子类别创建用户请求之后,如果已将请求模板添加或删除到服务子类别,则结果将是错误的。

SELECT u,rt FROM UserRequest AS u
JOIN ServiceSubcategory AS ss ON u.servicesubcategory_id=ss.id
JOIN RequestTemplate AS rt ON rt.servicesubcategory_id=ss.id
WHERE ISNULL(rt.name) = 1

问题:我可以针对UserRequest的搜索在关联的请求模板的字段中确实具有特定的价值的问题吗?
答:是,并且具有足够的版本(2.1.0以上)

Searching for a value
 
SELECT UserRequest AS u 
  JOIN TemplateFieldValue AS v ON v.obj_key=u.id
  WHERE v.template_name="Laptop ordering"
    AND field_code='size' 
    AND field_value='wide'

您必须指定请求模板的名称(或ID),因为field_code可能不足以唯一地标识特定模板,因此相同的代码可以用于多个模板。

Searching for a related object
 
SELECT u,m FROM UserRequest AS u 
  JOIN TemplateFieldValueLnk AS v ON v.obj_key=u.id
  JOIN Model AS m ON v.field_target_key = m.id
  WHERE v.template_name="Desktop ordering details"
    AND field_code='model' 
    AND field_target_class='Model'

问题:我已经安装了版本2.1,但是OQL查询不会返回旧的用户请求。
答:对于此扩展的版本2.1.0或更高版本,如果要对在部署此版本之前发出的用户请求执行查询,则必须启动一次,cli脚本会将之前创建的版本分解为新的可查询的对象。

该命令必须使用Web用户在iTop服务器上:

cd /path/to/itop/
cd env-production/templates-base/
php populateTemplateFieldValue.php --append

此命令将尚未爆炸的CustomAttribute数据分解为新对象TemplateFieldValue和TemplateFieldValueLnk。

注意:备用模式是php populateTemplateFieldValue.php –reset,它清空新表并从头开始重建它们。在升级转换为2.1之后,这两种模式非常相似。

始终首先在集成环境上运行这种繁琐的脚本,并附带生产数据的副本

您应该在Web服务器用户上运行此命令,否则可能难以访问dataacache-productionn内部的缓存文件。

原贴链接:https://www.itophub.io/wiki/page?id=extensions%3Arequest-templates


Customized request forms

name:
Customized request forms
description:
Define personalized request forms based on the service catalog. Add extra fields for a given type of request.
version:
2.1.2
release:
2020-03-27
itop-version-min:
2.3.2
code:
combodo-customized-request-forms
state:
stable
alternate-name:
Request Templates
diffusion:
iTop Hub

Check the upgrade process, if you upgrade from a version before 2.1.0 of this extension

Other versions of this component: 1.0.5

Features

This module provides the capability to add dynamically additional fields on a User Request in order to better qualify it. The additional fields proposed will be different based on the selected Service / Service Subcategory.

For instance when a user asks for a “new virtual machine”, then we may want him to provide the number of CPUs, the quantity of RAM and the type of OS in structured fields rather than hoping that the user will provide them by himself, in the Description field.

You just have to define your template and then when a user creates a ticket, the additional fields will appear in the ticket edition form, based on the selected service subcategory.

A request template is related to a service subcategory. A request template can add one or multiple additional fields to User Requests. The additional fields can be of the following types:

  • Date and Date Time

  • String (formated with regular expression if needed)

  • Text area

  • CSV list

  • List based on OQL query

  • Duration

  • Readonly/hidden fields

Revision History

Release DateVersionComments
2020-03-262.1.1- Fix regression when submitting with transition form
- Fix remove TemplateFieldValue on object deletion
2019-12-042.1.0- Request template fields are now queryable
- Fix missing menus on request template view
- Update DE translations
2019-01-302.0.14Fix regression introduced in 2.0.10: custom date formats no longer working
2018-12-192.0.13- Fix unnecessary error messages popping on the screen when a DoCheckToWrite fails
- Fix execution notice (check array existence)
- Update spanish translations (thanks to Miguel Turrubiates!)
2018-06-272.0.12Add DE translation
2018-06-262.0.11ES + BR translations, default search attributes
2018-01-262.0.10Ticket fields can now be used in customized forms.
Also fixed 2 bugs for usage in notifications templates ($service_details$) :
- N°1079 When the user leaves it undefined, then this is shown as an error message in the email: “Custom field error: Wrong format: missing template_data” ;
- N°1080 When a field aims at selecting an object, the email body shows the id of the selected object.
2018-01-052.0.9Customized forms are now compatible with Incident
2017-11-132.0.8Service_details is now documented on UserRequest creation before notification
2017-09-082.0.7Request template value not set in notification when creating an object
2017-03-012.0.6Added module setting to reset template fields value when changing to a different template that contains fields with same codes
2016-12-132.0.5Fixed issues when used in cunjunction with the legacy portal. Requires iTop > 2.3.2 for the date/time pickers to work fine
2016-11-292.0.4Implemented placeholders (e.g. $this->html(service_details)$. Requires iTop > 2.3.1 for the placeholders to work fine.
2016-09-082.0.3Added validation pattern to Date and DateTime fields. Fixed a PHP Warning when launching the cron manually.
2016-09-022.0.2Hidden and Read-only fields are now rendered like multiline strings (like a textarea, though it is read-only) - Note that this will work fine in the console with iTop 2.3.0+, but requires iTop > 2.3.1 to take advantage of this enhancement in the enhanced customer portal (no change in the legacy portal!)
2016-08-032.0.1Support of the console and the enhanced customer portal (both require iTop 2.3.0, otherwise the behavior is the same as 1.0.5)
2015-11-261.0.5Fix for crash when submitting a ticket from the portal for a template with an ENUM field containing some special characters.
2015-09-291.0.4Fix for a crash when a “drop-down list” field contains some weird characters (accents, question marks…) at the beginning of the list of values.
2014-12-101.0.3Cosmetics on the module name.
2014-04-031.0.2Minor fix to allow non admin users to import Template fields in CSV.
2014-03-101.0.1Bug fix for template fields with the same name as an attribute of the object.
2014-02-051.0.0First version, never validated.

Limitations

The placeholders will not work with iTop 2.3.1 and older.

Installation & upgrade

Use the Standard installation process for this extension.

Upgrade: In order to be able to search for old User Requests which do have a particular value set in a request template, the iTop administrator need to run once a special page which explode every (User Request) template data into new tables, so it can be queried with OQL.

php populateTemplateFieldValue.php --append

You can either use “--append” or “--reset”, same results, might differ in execution time.

  • --reset recomputes from scratch

  • --append explode only the template data which have not been exploded yet

Configuration

The following settings can be adjusted in the iTop configuration file, in the section itop-request-template:

ParameterTypeDescriptionDefault Value
copy_to_logstringThe attribute into which the template values should be copied. Set to an empty string to disable this behavior.public_log

The following settings can be adjusted in the iTop configuration file, in the section templates-base:

ParameterTypeDescriptionDefault Value
hidden_fields_profilesstringCSV list of profiles. If the user has ANY of the listed profile, she will NOT see the fields of type “hidden”.Portal user
reset_fields_on_template_changebooleanIf set to “true”, fields value will be reset when changing template, even if some of the fields have the same code.false
view_extra_datastringFIXMErelations

Usage

Create request template

From the Service Management menu, click on “Request template”:https://www.itophub.io/wiki/media?w=200&tok=23c619&media=extensions%3Aitop-request-template-menu.png

The pages show a list of already defined request templates. Click on the button “new” to create a new one:

https://www.itophub.io/wiki/media?w=300&tok=cd18b3&media=extensions%3Aitop-request-template-new.png

A request template is identified by its name the related service and service sub category.

The label is used on the portal to select a template if several are defined for a given service sub category.

The tab “Fields” is used to define the fields of the template:

https://www.itophub.io/wiki/media?w=800&tok=b80b46&media=extensions%3Aitop-request-template-list-field.png

Click on “Create a new field” to define a new one:

https://www.itophub.io/wiki/media?w=300&tok=c4b80b&media=extensions%3Aitop-request-template-create-field.png

Here is a complete description of the properties:

PropertyDescriptionExample
CodeUnique identifier, that can be used in the queries defined in another field. This value must be made of alphanumeric characters and cannot start with a numbermodel
OrderAn integer that defines in which order the fields are displayed in the form3
LabelLabel seen by the user who is prompted for entering a valueDevice Model
MandatoryWether or not the user must enter/select a valueyes
Input type… see a detailed description hereaboveList
Values (OQL or CSV)Used for drop-down lists only to define the list of allowed values for this element. This can be either a comma separated list of values (e.g. “high,medium,low”). The OQL can have a parameter in the form :template->code, where code is the code of another field. It can also use placeholder like :current_contact->org_id or :this->org_id which refer to the customer of the TicketSELECT Model WHERE brand_id = :template->brand
Initial valueUsed to set an initial value for text or text area fieldsxyz
FormatAllows you to define a regular expression for validating text fields^[a-zA-Z]$

When providing “Values” in CSV: write all values in one line, without carriage return

When providing “Values” in OQL: do not use friendlyname in the OQL query.

To limit to …use this regex within Format
an email[a-zA-Z0-9._&'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}
a phone number^\+?[0-9\ ]{8,20}$
a urlhttps?,ftp)\://([a-zA-Z0-9+!*(),;?&=\$_.-]+(\:[a-zA-Z0-9+!*(),;?&=\$_.-]+)?@)?([a-zA-Z0-9-.]{3,})(\:[0-9]{2,5})?(/([a-zA-Z0-9%+\$_-]\.?)+)*/?(\?[a-zA-Z+&\$_.-][a-zA-Z0-9;:[\]@&%=+/\$_.-]*)?(#[a-zA-Z_.-][a-zA-Z0-9+\$_.-]*)?

The input type can have one of the following values:

Input typeDescription
DateA pure date, entered by the mean of a calendar, or directly typed in
Date and timeDate and time, entered by the mean of a calendar, or directly typed in
Drop-down listA list as defined by the property Values
DurationA time lapse
HiddenA value that will not be seen by the end-user (customer portal), but it will be seen by an agent (console). The value is set by the mean of the property Initial value
ListA value to select amongst a list of proposed values. These values are defined by the mean of the property Values …
Read-onlyA value defined in Initial value, and which cannot be modified by anybody
TextA single line of text, which format may be enforced by setting Format
Text areaA text with several lines

The tab “Preview” displays a preview of the template as it will be displayed in the console:

https://www.itophub.io/wiki/media?w=300&tok=883cbf&media=extensions%3Aitop-request-template-preview.png

Behavior on the Customer Portal

If a end-user selects a service sub-category on the customer portal which is related to a request template, the specific fields for this template are displayed, grouped under the denomination Service details.

https://www.itophub.io/wiki/media?w=500&tok=2335d0&media=extensions%3Aitop-request-template-portal-enhanced.png

This additional information is copied into the Public log when the User Request is created:

https://www.itophub.io/wiki/media?media=extensions%3Aitop-request-template-public-log-enhanced.png

It is also possible for a Support Agent to see or edit the information in the details of the User Request, from the console:

https://www.itophub.io/wiki/media?w=500&tok=ae4406&media=extensions%3Aitop-request-template-console.png

Template placeholders

In a notification template, or anywhere else where a template can be used, the following placeholders will be available.

Assuming that this is a UserRequest:

  • $this->service_details$: a plain text representation of the selected values. This is suitable for a plain text email. Though it seems possible to use it within an HTML document, by using a PRE tag, this is NOT recommended because HTML entities (like <) still need to be escaped.

  • $this->html(service_details)$: an HTML representation of the selected values.

Hidden fields are forcibly excluded from the placeholders.

When a template value corresponds to an object selected into iTop, the returned value will be the friendly name of the object.

Questions & Answers

Question: Can I get the UserRequest which do not have a associated Request Template
Answer: Yes & No.

Query like this will fails

 SELECT UserRequest WHERE ISNULL(service_details) = 1

While such query will work, with the limitation that if you have added or removed Request Template to service subcategories after the creation of User Request using those service Subcategories, then the result will be wrong.

SELECT u,rt FROM UserRequest AS u
JOIN ServiceSubcategory AS ss ON u.servicesubcategory_id=ss.id
JOIN RequestTemplate AS rt ON rt.servicesubcategory_id=ss.id
WHERE ISNULL(rt.name) = 1

Question: Can I search for UserRequest which do have a particular value in a field of the associated Request Template
Answer: Yes with a recent enough version (above 2.1.0)

Searching for a value
 
SELECT UserRequest AS u 
  JOIN TemplateFieldValue AS v ON v.obj_key=u.id
  WHERE v.template_name="Laptop ordering"
    AND field_code='size' 
    AND field_value='wide'

You must specify the name (or id) of the Request Template, as the field_code may not be sufficient to identify uniquely a particular template, the same code could be used on multiple Templates.

Searching for a related object
 
SELECT u,m FROM UserRequest AS u 
  JOIN TemplateFieldValueLnk AS v ON v.obj_key=u.id
  JOIN Model AS m ON v.field_target_key = m.id
  WHERE v.template_name="Desktop ordering details"
    AND field_code='model' 
    AND field_target_class='Model'

Question: I have installed version 2.1, but OQL queries does not return old User Request.
Answer: With version 2.1.0 or above of this extension, if you want to perform queries over User Requests made prior to the deployement of this version, you have to launch once, a cli script which will explode the data created before into the new queryable objects.

The command requires to be on iTop server using the web user:

cd /path/to/itop/
cd env-production/templates-base/
php populateTemplateFieldValue.php --append

This command explodes not-yet-exploded CustomAttribute data into new objects TemplateFieldValue and TemplateFieldValueLnk.

Note: An alternate mode is php populateTemplateFieldValue.php –reset which empty the new tables and rebuild them from scratch. Just after the upgrade to 2.1, the 2 modes are pretty similar.

Always run this kind of heavy script on your integration environment first, with a copy of your production data

You should run this command with your webserver user, otherwise you may have difficulties to access cache files inside data/cache-production/

标签:
由 superadmin 在 2020/08/27, 16:05 创建
    

需要帮助?

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

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