-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
146 lines (115 loc) · 6.28 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
NAME
RT::Extension::DBCustomField - Link custom field values with external
sources
DESCRIPTION
This extension allows to link custom field values to external databases.
Specific custom field types provided by this extension allow users to
choose from a list of suggestions what they want to associate with a
ticket. This works with the help of auto-completion which is invoked
once a user typed two or more characters.
Stored and displayed is by default what the user chose. However, by
configuring custom templates it is possible to change what is displayed
to the user. This applies to the list of suggestions as well as to the
actual value users will see when viewing the ticket.
Pleaes note that what is displayed to the user is not necessarily what
is internally stored by RT for the custom field. Any time a ticket is
viewed by a user the extension fetches what to display from the external
database. This way it is possible to e.g. only store a primary key value
and display just an associated name to users.
RT VERSION
Works with RT 4.4.2
REQUIREMENTS
DBI (>= 1.37)
As well as an appropriate driver for the databases you want to
integrate. (e.g. DBD::mysql for MySQL)
INSTALLATION
perl Makefile.PL
make
make install
May need root permissions
Edit your /opt/rt4/etc/RT_SiteConfig.pm
Add this line:
Plugin('RT::Extension::DBCustomField');
Clear your mason cache
rm -rf /opt/rt4/var/mason_data/obj
Restart your webserver
CONFIGURATION
First you need to define $DBCustomField_Connections which is a hash of
available database connections.
Set($DBCustomField_Connections, {
'sugarcrm' => {
'dsn' => 'DBI:mysql:database=SUGARCRMDB;host=MYHOST;port=3306;mysql_enable_utf8=1',
'username' => 'USER',
'password' => 'PASS'
}
});
Then it is required to define $DBCustomField_Queries which is a hash of
available query definitions. Every query definition has a name and
consists of two queries. One for the auto-completion suggestions and one
to fetch display values with.
Set ($DBCustomField_Queries, {
'companies' => {
# The connection to use
'connection' => 'sugarcrm',
# The query to fetch auto-completion suggestions with. `field_value' is mandatory
# and any occurrence of `?' is replaced with a user's input.
'suggestions' => q{
SELECT
cstm.net_global_id_c AS field_value, cstm.shortname_c AS shortname, a.name
FROM accounts a
INNER JOIN accounts_cstm cstm ON cstm.id_c = a.id AND cstm.net_global_id_c
WHERE a.deleted = 0 AND (cstm.net_global_id_c = ? OR cstm.shortname_c LIKE ? OR a.name LIKE ?)
ORDER BY shortname
},
# The display template to use for each entry returned by the suggestions query. To reference specific
# columns here encapsulate their name with curly braces. The default is just `{field_value}'
# HTML support: Yes
'suggestions_tpl' => q{
<div>
<strong>{shortname}</strong>
<div>{name} (<strong>{field_value}</strong>)</div>
</div>
},
# The query to fetch display values with. `field_value' is only required when not defining
# a custom display template. A single occurrence of `?' is replaced with the value internally
# stored by RT.
'display_value' => q{
SELECT
cstm.net_global_id_c AS field_value, cstm.shortname_c AS shortname
FROM accounts a
INNER JOIN accounts_cstm cstm ON cstm.id_c = a.id AND cstm.net_global_id_c
WHERE cstm.net_global_id_c = ?
},
# The display template to use when showing the custom field value to users. To reference specific
# columns here encapsulate their name with curly braces. The default is just `{field_value}'.
# HTML support: Yes, but try to avoid manipulating the layout too much (e.g. with block elements)
'display_value_tpl' => '{shortname} (<i>{field_value}</i>)'
},
});
Last you need to define $DBCustomField_Fields which maps query
definitions to specific custom fields. This controls which suggestions a
user receives when typing something into a custom field input. Note that
these custom fields need to be of the type provided by this extension.
Set($DBCustomField_Fields, {
'Client' => 'companies'
});
By default the limit of suggestions displayed to the user is 10. To
adjust this you can use the following:
Set($DBCustomField_Suggestion_Limit, 25);
ADVANCED CONFIGURATION
__TICKET__
Can be used as part of any query to reference a ticket's ID. (Is
replaced by this extension with an integer.)
__VALUE__
Can be used only as part of the `display_value' query to reference
the `field_value'. (Is replaced by this extension with whatever has
been stored internally by RT.)
AUTHOR
NETWAYS GmbH <[email protected]>
BUGS
All bugs should be reported on GitHub
<https://github.com/NETWAYS/rt-extension-dbcustomfield>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 by NETWAYS GmbH
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991