RT::CustomField_Overlay - overlay for RT::CustomField
Create takes a hash of values and creates a row in the database:
varchar(200) 'Name'.
varchar(200) 'Type'.
int(11) 'MaxValues'.
varchar(255) 'Pattern'.
varchar(255) 'Description'.
int(11) 'SortOrder'.
varchar(255) 'LookupType'.
varchar(255) 'EntryHint'.
smallint(6) 'Disabled'.
LookupType
is generally the result of either RT::Ticket-
CustomFieldLookupType> or RT::Transaction-
CustomFieldLookupType>.
Load a custom field. If the value handed in is an integer, load by custom field ID. Otherwise, Load by name.
NAME
, [...]Loads the Custom field named NAME. As other optional parameters, takes:
LOOKUPTYPE
The type of Custom Field to look for; while this parameter is not required, it is highly suggested, or you may not find the Custom Field you are expecting. It should be passed a LookupType
such as "CustomFieldLookupType" in RT::Ticket or "CustomFieldLookupType" in RT::User.
CLASS
The class of object that the custom field is applied to. This can be intuited from the provided LookupType
.
ID
limits the custom field search to one applied to the relevant id. For example, if a LookupType
of RT::Ticket->CustomFieldLookupType
is used, this is which Queue the CF must be applied to. Pass 0 to only search custom fields that are applied globally.
BOOLEAN
Whether it should return Disabled custom fields if they match; defaults to on, though non-Disabled custom fields are returned preferentially.
BOOLEAN
Whether to also search global custom fields, even if a value is provided for ObjectId
; defaults to off. Non-global custom fields are returned preferentially.
For backwards compatibility, a value passed for Queue
is equivalent to specifying a LookupType
of "CustomFieldLookupType" in RT::Ticket, and a ObjectId
of the value passed as Queue
.
If multiple custom fields match the above constraints, the first according to SortOrder
will be returned; ties are broken by id
, lowest-first.
Deprecated alternate names for "LoadByName".
Return a object (collection) of all acceptable values for this Custom Field. Class of the object can vary and depends on the return value of the ValuesClass
method.
Create a new value for this CustomField. Takes a paramhash containing the elements Name, Description and SortOrder
Deletes a value from this custom field by id.
Does not remove this value for any article which has had it selected
Make sure that the name specified is valid
Make sure that the queue specified is a valid queue name
Retuns an array of the types of CustomField that are supported
Returns a boolean value indicating whether the Values
method makes sense to this Custom Field.
Returns a boolean value indicating whether the type of this custom field permits using a canonicalizer.
Writer method for the ValuesClass field; validates that the custom field can use a ValuesClass, and that the provided ValuesClass passes "ValidateValuesClass".
Validates a potential ValuesClass value; the ValuesClass may be undef
or the string "RT::CustomFieldValues"
(both of which make this custom field use the ordinary values implementation), or a class name in the listed in the "@CustomFieldValuesSources" in RT_Config setting.
Returns true if valid; false if invalid.
Writer method for the CanonicalizeClass field; validates that the custom field can use a CanonicalizeClass, and that the provided CanonicalizeClass passes "ValidateCanonicalizeClass".
Validates a potential CanonicalizeClass value; the CanonicalizeClass may be undef
(which make this custom field use no special canonicalization), or a class name in the listed in the "@CustomFieldValuesCanonicalizers" in RT_Config setting.
Returns true if valid; false if invalid.
Returns a localized human-readable version of the custom field type. If a custom field type is specified as the parameter, the friendly type for that type will be returned
Takes a single string. returns true if that string is a value type of custom field
Takes a single string representing a regular expression. Performs basic validation on that regex, and sets the Pattern
field for the CF if it is valid.
Tests if the string contains an invalid regex.
Returns true if this CustomField only accepts a single value. Returns false if it accepts multiple values
Returns list of objects via which users can get rights on this custom field. For custom fields these objects can be set using ContextObject.
Set or get a context for this object. It can be ticket, queue or another object this CF added to. Used for ACL control, for example SeeCustomField can be granted on queue level to allow people to see all fields added to the queue.
Takes an Id for a Context Object and loads the right kind of RT::Object for this particular Custom Field (based on the LookupType) and returns it. This is a good way to ensure you don't try to use a Queue as a Context Object on a User Custom Field.
Ensure that a given ContextObject applies to this Custom Field. For custom fields that are assigned to Queues or to Classes, this checks that the Custom Field is actually added to that object. For Global Custom Fields, it returns true as long as the Object is of the right type, because you may be using your permissions on a given Queue of Class to see a Global CF. For CFs that are only added globally, you don't need a ContextObject.
Takes the name of a table column. Returns its value as a string, if the user passes an ACL check
Takes a boolean. 1 will cause this custom field to no longer be avaialble for objects. 0 will re-enable this field.
Set this custom field's type and maximum values as a composite value
Returns a composite value composed of this object's type and maximum values
Returns an array of all possible composite values for custom fields.
Returns the type of form widget to render for this custom field. Currently this only affects fields which return true for "HasRenderTypes".
Sets this custom field's render type.
Returns the default render type for this custom field's type or the TYPE COMPOSITE specified as an argument.
Returns a boolean value indicating whether the "RenderTypes" and "RenderType" methods make sense for this custom field.
Currently true only for type Select
.
Returns the valid render types for this custom field's type or the TYPE COMPOSITE specified as an argument.
Autrijus: care to doc how LookupTypes work?
Returns an array of LookupTypes available
Returns a localized description of the type of this custom field
Returns the type of Object referred to by ObjectCustomFields' ObjectId column
Optionally takes a LookupType to use instead of using the value on the loaded record. In this case, the method may be called on the class instead of an object.
Returns the ObjectType used in ObjectCustomFieldValues rows for this CF
Optionally takes a LookupType to use instead of using the value on the loaded record. In this case, the method may be called on the class instead of an object.
Returns a (sorted and lowercased) list of the groupings in which this custom field appears.
If called on a loaded object, the returned list is limited to groupings which apply to the record class this CF applies to ("RecordClassFromLookupType").
If passed a loaded object or a class name, the returned list is limited to groupings which apply to the class of the object or the specified class.
If called on an unloaded object, all potential groupings are returned.
Identical to "Groupings" but filters out built-in groupings from the the returned list.
Registers groupings to be considered a fundamental part of RT, either via use in core RT or via an extension. These groupings must be rendered explicitly in Mason by specific calls to /Elements/ShowCustomFields and /Elements/EditCustomFields. They will not show up automatically on normal display pages like configured custom groupings.
Takes a set of key-value pairs of class names (valid RT::Record subclasses) and array refs of grouping names to consider built-in.
If a class already contains built-in groupings (such as RT::Ticket and RT::User), new groupings are appended.
Certain custom fields (users, groups) should only be added globally; codify that set here for reference.
Returns collection with objects this custom field is added to. Class of the collection depends on "LookupType". See all "NotAddedTo" .
Doesn't takes into account if object is added globally.
Returns collection with objects this custom field is not added to. Class of the collection depends on "LookupType". See all "AddedTo" .
Doesn't take into account if the object is added globally.
Takes object id and returns corresponding RT::ObjectCustomField record if this custom field is added to the object. Use 0 to check if custom field is added globally.
Returns true if custom field is applied to any object.
Add this custom field as a custom field for a single object, such as a queue or group.
Takes an object
Remove this custom field for a single object, such as a queue or group.
Takes an object
Adds a custom field value for a record object of some kind. Takes a param hash of
Required:
Object
Content
Optional:
LargeContent
ContentType
Tests the incoming string against the Pattern of this custom field object and returns a boolean; returns true if the Pattern is empty.
Prettify the pattern of this custom field, by taking the text in (?#text)
and localizing it.
Deletes a custom field value for a ticket. Takes a param hash of Object and Content
Returns a tuple of (STATUS, MESSAGE). If the call succeeded, the STATUS is true. otherwise it's false
Return an RT::ObjectCustomFieldValues object containing all of this custom field's values for OBJECT
If the user has SeeCustomField they can see this custom field and its details.
Otherwise, if the user has SetInitialCustomField and this is being used in a "create" context, then they can see this custom field and its details. This allows you to set up custom fields that are only visible on create pages and are then inaccessible.
Tell RT that a certain object accepts custom fields via a lookup type and provide a friendly name for such CFs.
Examples:
'RT::Queue-RT::Ticket' => "Tickets", # loc
'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions", # loc
'RT::User' => "Users", # loc
'RT::Group' => "Groups", # loc
'RT::Queue' => "Queues", # loc
This is a class method.
Gets or sets the IncludeContentForValue
for this custom field. RT uses this field to automatically include content into the user's browser as they display records with custom fields in RT.
Gets or sets the LinkValueTo
for this custom field. RT uses this field to make custom field values into hyperlinks in the user's browser as they display records with custom fields in RT.
With one argument, returns the _URLTemplate named NAME
, but only if the current user has the right to see this custom field.
With two arguments, attemptes to set the relevant template value.
Returns the current value of id. (In the database, id is stored as int(11).)
Returns the current value of Name. (In the database, Name is stored as varchar(200).)
Set Name to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Name will be stored as a varchar(200).)
Returns the current value of Type. (In the database, Type is stored as varchar(200).)
Set Type to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Type will be stored as a varchar(200).)
Returns the current value of RenderType. (In the database, RenderType is stored as varchar(64).)
Set RenderType to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, RenderType will be stored as a varchar(64).)
Returns the current value of MaxValues. (In the database, MaxValues is stored as int(11).)
Set MaxValues to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, MaxValues will be stored as a int(11).)
Returns the current value of Pattern. (In the database, Pattern is stored as text.)
Set Pattern to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Pattern will be stored as a text.)
Returns the current value of BasedOn. (In the database, BasedOn is stored as int(11).)
Set BasedOn to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, BasedOn will be stored as a int(11).)
Returns the current value of Description. (In the database, Description is stored as varchar(255).)
Set Description to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Description will be stored as a varchar(255).)
Returns the current value of SortOrder. (In the database, SortOrder is stored as int(11).)
Set SortOrder to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, SortOrder will be stored as a int(11).)
Returns the current value of LookupType. (In the database, LookupType is stored as varchar(255).)
Set LookupType to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, LookupType will be stored as a varchar(255).)
Set EntryHint to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, EntryHint will be stored as a varchar(255).)
Returns the current value of Creator. (In the database, Creator is stored as int(11).)
Returns the current value of Created. (In the database, Created is stored as datetime.)
Returns the current value of LastUpdatedBy. (In the database, LastUpdatedBy is stored as int(11).)
Returns the current value of LastUpdated. (In the database, LastUpdated is stored as datetime.)
Returns the current value of Disabled. (In the database, Disabled is stored as smallint(6).)
Set Disabled to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Disabled will be stored as a smallint(6).)
Loads the described asset custom field, if one is found, into the current object. This method only consults custom fields applied to RT::Catalog for RT::Asset objects.
Takes a hash with the keys:
A RT::CustomField ID or Name which applies to assets.
Optional. An RT::Catalog ID or Name.
If Catalog is specified, only a custom field added to that Catalog will be loaded.
If Catalog is 0
, only global asset custom fields will be loaded.
If no Catalog is specified, all asset custom fields are searched including global and catalog-specific CFs.
Please note that this method may load a Disabled custom field if no others matching the same criteria are found. Enabled CFs are preferentially loaded.
← Back to index