|
|
Data Groups
| Description |
|
A Data Group is quite simply a list.
It consists of a list of data type elements loaded from database,
a list of values manually typed in, or of a list of values created
dynamically by javascript code.
You can view the existing data types and create new ones by browsing to:
Admin ->
Settings Administration ->
Edit Data Groups
|
| Fields for a Data Group |
| Field |
Purpose |
| Table Name |
Name of the data type table to reference. Set this to custom
if you will be entering values manually (instead of selecting them
from the database list) or if you will be using javascript.
|
| Group Name |
A descriptive name for your group, such as 'Priorities for Engineering'
|
| Opis |
Any comments or notes you need about this group.
|
| Eval Type |
Use 'Matches' to select a list of entries from a database or
to manually type in choices.
Use Javascript to enter javascript code which will create
the list of entries.
|
| Eval Script |
This is only active when the Eval Type is set to Javascript.
Javascript can be pasted into this box directly as it will be evaluated.
See the section below on Javascript Lists for more info on this field.
|
|
| Data Type Lists |
|
A data type list is created by selecting the name of a table from the
Table Name field. Once the data group is created, you may
click on the Entries link to select items from a list of
valid entries.
A data type list is the preferred way to use the data group
feature.
|
| Custom (manually entered) Lists |
|
A custom list is created by selecting the 'Custom' option
from the Table Name field and 'Matches' from the
Eval Type field.
Once the data group is created, clicking on the
Entries link will produce a menu where you
can manually type in the choices that will appear.
A custom list is not advised for use with any standard ticket
fields, but is fine for use with the Variable Field values.
|
| Lists Created from Files |
|
By selecting the Eval Type of 'File', you can use the contents of a
tab delimited text file to create data groups. This feature is designed
to be used with behaviors.
The file to be used should be placed in the zentrack/includes/user_data
folder.
Once this is completed, the rest of the work is done from the behaviors
screen.
|
| Javascript Lists |
|
Javascript lists should always be used with a great deal of caution, and
are not recommended for anyone without extensive programming experience.
Javascript lists are created by selecting the 'Custom' option
from the Table Name field and 'Javascript' from the
Eval Type field.
You will not use the Entries link with Javascript lists.
The javascript code is expected to create an array named x which
will contain a simple array of values or an array of objects
with two properties: label and value.
Several special properties can be substituted into the javascript code to
reference variables dynamically at runtime. They are described in the following
table:
| Variable | Description |
| {form} |
At runtime, this special reference is replaced by the complete form name,
such as window.document.forms['searchForm']
|
| {field} |
Like the {form} reference, but references the field that the data group
has been assigned to.
|
| {id} |
The id of the ticket being viewed (note that this may not always be
available, such as when creating a new ticket)
|
| {view} |
The current page being viewed. This variable is considered untested
and may not always function as expected.
|
| {login_id} |
user_id for the logged in user
|
| {login_name} |
Full display name of the logged in user
|
| {login_language} |
Language currently being displayed
|
| {login_inits} |
Initials for the logged in user
|
| {username} |
The login name which was used by the current user to login.
|
Here are some examples:
| Example 1: Simple Array |
This javascript code:
var x = new Array();
for(i=1; i < 4; i++) {
//each entry is just the value of i
x[ x.length ] = i;
}
Would create:
[ 1, 2, 3 ]
Thus, a menu using these values would get:
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
A text field using these values would just get:
<input type='...' value='1'>
|
A more complex example:
| Example 2: Object Array |
This Code:
var x = new Array();
for(i=1; i < 4; i++) {
//each value is an object with a label and value
x[ x.length ] = { label:'item_'+i, value:i };
}
Would create:
[
[ 'item_1', 1 ],
[ 'item_2', 2 ],
[ 'item_3', 3 ]
]
Thus, a menu using these values would get:
<option value='1'>item_1</option>
<option value='2'>item_2</option>
<option value='3'>item_3</option>
A text field using these values would just get:
<input type='...' value='1'>
|
Using the {form} property:
| Example 3: The {form} property |
Assuming that:
<input type='text' name='custom_number1' value='10'>
This Code:
var x = new Array();
var x[0] = {form}.custom_number1 + 20;
Would Create:
[ 30 ]
Thus, a menu using these values would get:
<option value='30'>30</option>
A text field using these values would just get:
<input type='...' value='30'>
|
A very complex example:
| Example 4: Very complex javascript replace |
Assuming that:
<select name='priority>
<option value='1'>high</option>
<option value='2'>medium</option>
<option value='3'>low</option>
</select>
<input type='text' name='custom_string_1' value='aaaa'>
<input type='text' name='custom_string_2' value='bbbb'>
This Code:
// this script adds values placed in custom_string1
// and custom_string2 to the priorities dropdown
// create our array which will be used to populate fields
var x = new Array();
// shortcut to the options in the priority menu
var options = {form}.priority.options;
// shortcut to value of custom_string fields
var f1 = {form}.custom_string1.value;
var f2 = {form}.custom_string2.value;
// recreate menu with existing values
for( var i=0; i < options.length; i++ ) {
// insert each value of the existing menu
// into our new array
x[ x.length ] =
{ label:options[i].text, value:options[i].value };
// make sure the menu doesn't already contain our field
// values, if so, then make sure we don't add them again
if( options[i].value == f1 ) { f1 = null; }
if( options[i].value == f2 ) { f2 = null; }
}
// add values of our custom fields to the array
if( f1 ) {
x[ x.length ] = f1;
}
if( f2 ) {
x[ x.length ] = f2;
}
// now when this is evaluated, the array x will
// contain the existing menu values plus anything
// we have added via the custom_string fields!
Would Create:
[
{ label:'high', value:1 }
{ label:'medium', value:2 }
{ label:'low', value:3 }
[ aaaa ]
[ bbbb ]
]
Thus, a menu using these values would get:
<option value='1'>high</option>
<option value='2'>medium</option>
<option value='3'>low</option>
<option value='aaaa'>aaaa</option>
<option value='bbbb'>bbbb</option>
A text field using these values would just get:
<input type='...' value='1'>
(not really useful here)
|
|
|