RT 4.0.24 Documentation

This version has reached its end of life and is out of support. Please contact us for upgrade assistance.

RT::CustomField

Go to latest version →

AddRights RIGHT, DESCRIPTION [, ...]

Adds the given rights to the list of possible rights. This method should be called during server startup, not at runtime.

RightCategories

Returns a hashref where the keys are rights for this type of object and the values are the category (General, Staff, Admin) the right falls into.

AddRightCategories RIGHT, CATEGORY [, ...]

Adds the given right and category pairs to the list of right categories. 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 name specified is valid

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.

RenderType

Returns the type of form widget to render for this custom field. Currently this only affects fields which return true for "HasRenderTypes".

SetRenderType TYPE

Sets this custom field's render type.

DefaultRenderType [TYPE COMPOSITE]

Returns the default render type for this custom field's type or the TYPE COMPOSITE specified as an argument.

HasRenderTypes [TYPE_COMPOSITE]

Returns a boolean value indicating whether the "RenderTypes" and "RenderType" methods make sense for this custom field.

Currently true only for type Select.

RenderTypes [TYPE COMPOSITE]

Returns the valid render types for this custom field's type or the TYPE COMPOSITE specified as an argument.

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

RecordClassFromLookupType

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.

ObjectTypeFromLookupType

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.

ApplyGlobally

Certain custom fields (users, groups) should only be applied globally but rather than regexing in code for LookupType =~ RT::Queue, we'll codify the rules here.

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
    'RT::Queue'                            => "Queues",                 # 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.

id

Returns the current value of id. (In the database, id is stored as int(11).)

Name

Returns the current value of Name. (In the database, Name is stored as varchar(200).)

SetName VALUE

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).)

Type

Returns the current value of Type. (In the database, Type is stored as varchar(200).)

SetType VALUE

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).)

RenderType

Returns the current value of RenderType. (In the database, RenderType is stored as varchar(64).)

SetRenderType VALUE

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).)

MaxValues

Returns the current value of MaxValues. (In the database, MaxValues is stored as int(11).)

SetMaxValues VALUE

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).)

Pattern

Returns the current value of Pattern. (In the database, Pattern is stored as text.)

SetPattern VALUE

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.)

Repeated

Returns the current value of Repeated. (In the database, Repeated is stored as smallint(6).)

SetRepeated VALUE

Set Repeated to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Repeated will be stored as a smallint(6).)

BasedOn

Returns the current value of BasedOn. (In the database, BasedOn is stored as int(11).)

SetBasedOn VALUE

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).)

Description

Returns the current value of Description. (In the database, Description is stored as varchar(255).)

SetDescription VALUE

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).)

SortOrder

Returns the current value of SortOrder. (In the database, SortOrder is stored as int(11).)

SetSortOrder VALUE

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).)

LookupType

Returns the current value of LookupType. (In the database, LookupType is stored as varchar(255).)

SetLookupType VALUE

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).)

Creator

Returns the current value of Creator. (In the database, Creator is stored as int(11).)

Created

Returns the current value of Created. (In the database, Created is stored as datetime.)

LastUpdatedBy

Returns the current value of LastUpdatedBy. (In the database, LastUpdatedBy is stored as int(11).)

LastUpdated

Returns the current value of LastUpdated. (In the database, LastUpdated is stored as datetime.)

Disabled

Returns the current value of Disabled. (In the database, Disabled is stored as smallint(6).)

SetDisabled VALUE

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).)

← Back to index