RT 3.8.17 Documentation
RT::CustomField Overlay
- NAME
- DESCRIPTION
- 'CORE' METHODS
- Create PARAMHASH
- Load ID/NAME
- LoadByName (Queue => QUEUEID, Name => NAME)
- Custom field values
- ValidateQueue Queue
- Types
- IsSelectionType
- IsExternalValues
- FriendlyType [TYPE, MAX_VALUES]
- ValidateType TYPE
- SetPattern STRING
- _IsValidRegex(Str $regex) returns (Bool $success, Str $msg)
- SingleValue
- CurrentUserHasRight RIGHT
- ACLEquivalenceObjects
- ContextObject and SetContextObject
- LoadContextObject
- ValidateContextObject
- _Value
- SetDisabled
- SetTypeComposite
- TypeComposite
- TypeComposites
- SetLookupType
- LookupTypes
- FriendlyLookupType
- AppliedTo
- NotAppliedTo
- IsApplied
- AddToObject OBJECT
- RemoveFromObject OBJECT
- AddValueForObject HASH
- MatchPattern STRING
- FriendlyPattern
- DeleteValueForObject HASH
- ValuesForObject OBJECT
- _ForObjectType PATH FRIENDLYNAME
- IncludeContentForValue [VALUE] (and SetIncludeContentForValue)
- LinkValueTo [VALUE] (and SetLinkValueTo)
- _URLTemplate NAME [VALUE]
AddRights RIGHT
, DESCRIPTION
[, ...]
Adds the given rights to the list of possible rights. This method should be called during server startup, not at runtime.
NAME
RT::CustomField_Overlay - overlay for RT::CustomField
DESCRIPTION
'CORE' METHODS
Create PARAMHASH
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'.
smallint(6) 'Repeated'.
varchar(255) 'Description'.
int(11) 'SortOrder'.
varchar(255) 'LookupType'.
smallint(6) 'Disabled'.
LookupType
is generally the result of either RT::Ticket-
CustomFieldLookupType> or RT::Transaction-
CustomFieldLookupType>.
Load ID/NAME
Load a custom field. If the value handed in is an integer, load by custom field ID. Otherwise, Load by name.
LoadByName (Queue => QUEUEID, Name => NAME)
Loads the Custom field named NAME.
Will load a Disabled Custom Field even if there is a non-disabled Custom Field with the same Name.
If a Queue parameter is specified, only look for ticket custom fields tied to that Queue.
If the Queue parameter is '0', look for global ticket custom fields.
If no queue parameter is specified, look for any and all custom fields with this name.
BUG/TODO, this won't let you specify that you only want user or group CFs.
Custom field values
Values FIELD
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.
AddValue HASH
Create a new value for this CustomField. Takes a paramhash containing the elements Name, Description and SortOrder
DeleteValue ID
Deletes a value from this custom field by id.
Does not remove this value for any article which has had it selected
ValidateQueue Queue
Make sure that the queue specified is a valid queue name
Types
Retuns an array of the types of CustomField that are supported
IsSelectionType
Retuns a boolean value indicating whether the Values
method makes sense to this Custom Field.
IsExternalValues
FriendlyType [TYPE, MAX_VALUES]
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
ValidateType TYPE
Takes a single string. returns true if that string is a value type of custom field
SetPattern STRING
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.
_IsValidRegex(Str $regex) returns (Bool $success, Str $msg)
Tests if the string contains an invalid regex.
SingleValue
Returns true if this CustomField only accepts a single value. Returns false if it accepts multiple values
CurrentUserHasRight RIGHT
Helper function to call the custom field's queue's CurrentUserHasRight with the passed in args.
ACLEquivalenceObjects
Returns list of objects via which users can get rights on this custom field. For custom fields these objects can be set using ContextObject.
ContextObject and SetContextObject
Set or get a context for this object. It can be ticket, queue or another object this CF applies to. Used for ACL control, for example SeeCustomField can be granted on queue level to allow people to see all fields applied to the queue.
LoadContextObject
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.
ValidateContextObject
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 applied to that objects. 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 applied Globally, you don't need a ContextObject.
_Value
Takes the name of a table column. Returns its value as a string, if the user passes an ACL check
SetDisabled
Takes a boolean. 1 will cause this custom field to no longer be avaialble for objects. 0 will re-enable this field.
SetTypeComposite
Set this custom field's type and maximum values as a composite value
TypeComposite
Returns a composite value composed of this object's type and maximum values
TypeComposites
Returns an array of all possible composite values for custom fields.
SetLookupType
Autrijus: care to doc how LookupTypes work?
LookupTypes
Returns an array of LookupTypes available
FriendlyLookupType
Returns a localized description of the type of this custom field
AppliedTo
Returns collection with objects this custom field is applied to. Class of the collection depends on "LookupType". See all "NotAppliedTo" .
Doesn't takes into account if object is applied globally.
NotAppliedTo
Returns collection with objects this custom field is not applied to. Class of the collection depends on "LookupType". See all "AppliedTo" .
Doesn't takes into account if object is applied globally.
IsApplied
Takes object id and returns corresponding RT::ObjectCustomField record if this custom field is applied to the object. Use 0 to check if custom field is applied globally.
AddToObject OBJECT
Add this custom field as a custom field for a single object, such as a queue or group.
Takes an object
RemoveFromObject OBJECT
Remove this custom field for a single object, such as a queue or group.
Takes an object
AddValueForObject HASH
Adds a custom field value for a record object of some kind. Takes a param hash of
Required:
Object
Content
Optional:
LargeContent
ContentType
MatchPattern STRING
Tests the incoming string against the Pattern of this custom field object and returns a boolean; returns true if the Pattern is empty.
FriendlyPattern
Prettify the pattern of this custom field, by taking the text in (?#text)
and localizing it.
DeleteValueForObject HASH
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
ValuesForObject OBJECT
Return an RT::ObjectCustomFieldValues object containing all of this custom field's values for OBJECT
_ForObjectType PATH FRIENDLYNAME
Tell RT that a certain object accepts custom fields
Examples:
'RT::Queue-RT::Ticket' => "Tickets", # loc
'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions", # loc
'RT::User' => "Users", # loc
'RT::Group' => "Groups", # loc
This is a class method.
IncludeContentForValue [VALUE] (and SetIncludeContentForValue)
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.
LinkValueTo [VALUE] (and SetLinkValueTo)
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.
_URLTemplate NAME [VALUE]
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.
← Back to index