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::Record

Go to latest version →

NAME

  RT::Record - Base class for RT record objects

SYNOPSIS

DESCRIPTION

METHODS

_PrimaryKeys

The primary keys for RT classes is 'id'

Id

Override "Id" in DBIx::SearchBuilder to avoid a few lookups RT doesn't do on a very common codepath

id is an alias to Id and is the preferred way to call this method.

Delete

Delete this record object from the database.

ObjectTypeStr

Returns a string which is this object's type. The type is the class, without the "RT::" prefix.

Attributes

Return this object's attributes as an RT::Attributes object

AddAttribute { Name, Description, Content }

Adds a new attribute for this object.

SetAttribute { Name, Description, Content }

Like AddAttribute, but replaces all existing attributes with the same Name.

DeleteAttribute NAME

Deletes all attributes with the matching name for this object.

FirstAttribute NAME

Returns the first attribute with the matching name for this object (as an RT::Attribute object), or undef if no such attributes exist. If there is more than one attribute with the matching name on the object, the first value that was set is returned.

Create PARAMHASH

Takes a PARAMHASH of Column -> Value pairs. If any Column has a Validate$PARAMNAME subroutine defined and the value provided doesn't pass validation, this routine returns an error.

If this object's table has any of the following atetributes defined as 'Auto', this routine will automatically fill in their values.

Created
Creator
LastUpdated
LastUpdatedBy

LoadByCols

Override DBIx::SearchBuilder::LoadByCols to do case-insensitive loads if the DB is case sensitive

_SetLastUpdated

This routine updates the LastUpdated and LastUpdatedBy columns of the row in question It takes no options. Arguably, this is a bug

CreatorObj

Returns an RT::User object with the RT account of the creator of this row

LastUpdatedByObj

  Returns an RT::User object of the last user to touch this object

URI

Returns this record's URI

ValidateName NAME

Validate the name of the record we're creating. Mostly, just make sure it's not a numeric ID, which is invalid for Name

SQLType attribute

return the SQL type for the attribute 'attribute' as stored in _ClassAccessible

_ClassAccessible

Overrides the "core" _ClassAccessible using $_TABLE_ATTR. Behaves identical to the version in DBIx::SearchBuilder::Record

_Accessible COLUMN ATTRIBUTE

returns the value of ATTRIBUTE for COLUMN

_EncodeLOB BODY MIME_TYPE FILENAME

Takes a potentially large attachment. Returns (ContentEncoding, EncodedBody, MimeType, Filename) based on system configuration and selected database. Returns a custom (short) text/plain message if DropLongAttachments causes an attachment to not be stored.

Encodes your data as base64 or Quoted-Printable as needed based on your Databases's restrictions and the UTF-8ness of the data being passed in. Since we are storing in columns marked UTF8, we must ensure that binary data is encoded on databases which are strict.

This function expects to receive an octet string in order to properly evaluate and encode it. It will return an octet string.

_DecodeLOB ContentType, ContentEncoding, Content

Unpacks data stored in the database, which may be base64 or QP encoded because of our need to store binary and badly encoded data in columns marked as UTF-8. Databases such as PostgreSQL and Oracle care that you are feeding them invalid UTF-8 and will refuse the content. This function handles unpacking the encoded data.

It returns textual data as a UTF-8 string which has been processed by Encode's PERLQQ filter which will replace the invalid bytes with \x{HH} so you can see the invalid byte but won't run into problems treating the data as UTF-8 later.

This is similar to how we filter all data coming in via the web UI in RT::Interface::Web::DecodeARGS. This filter should only end up being applied to old data from less UTF-8-safe versions of RT.

If the passed ContentType includes a character set, that will be used to decode textual data; the default character set is UTF-8. This is necessary because while we attempt to store textual data as UTF-8, the definition of "textual" has migrated over time, and thus we may now need to attempt to decode data that was previously not trancoded on insertion.

Important Note - This function expects an octet string and returns a character string for non-binary data.

Update ARGSHASH

Updates fields on an object for you using the proper Set methods, skipping unchanged values.

 ARGSRef => a hashref of attributes => value for the update
 AttributesRef => an arrayref of keys in ARGSRef that should be updated
 AttributePrefix => a prefix that should be added to the attributes in AttributesRef
                    when looking up values in ARGSRef
                    Bare attributes are tried before prefixed attributes

Returns a list of localized results of the update

    "Ticket" # loc
    "User" # loc
    "Group" # loc
    "Queue" # loc
                                   "[_1] could not be set to [_2].",       # loc
                                   "That is already the current value",    # loc
                                   "No value sent to _Set!",               # loc
                                   "Illegal value for [_1]",               # loc
                                   "The new value has been set.",          # loc
                                   "No column specified",                  # loc
                                   "Immutable field",                      # loc
                                   "Nonexistant field?",                   # loc
                                   "Invalid data",                         # loc
                                   "Couldn't find row",                    # loc
                                   "Missing a primary key?: [_1]",         # loc
                                   "Found Object",                         # loc

Members

  This returns an RT::Links object which references all the tickets 
which are 'MembersOf' this ticket

MemberOf

  This returns an RT::Links object which references all the tickets that this
ticket is a 'MemberOf'

RefersTo

  This returns an RT::Links object which shows all references for which this ticket is a base

ReferredToBy

This returns an RT::Links object which shows all references for which this ticket is a target

DependedOnBy

  This returns an RT::Links object which references all the tickets that depend on this one

HasUnresolvedDependencies

Takes a paramhash of Type (default to '__any'). Returns the number of unresolved dependencies, if $self->UnresolvedDependencies returns an object with one or more members of that type. Returns false otherwise.

UnresolvedDependencies

Returns an RT::Tickets object of tickets which this ticket depends on and which have a status of new, open or stalled. (That list comes from RT::Queue->ActiveStatusArray

AllDependedOnBy

Returns an array of RT::Ticket objects which (directly or indirectly) depends on this ticket; takes an optional 'Type' argument in the param hash, which will limit returned tickets to that type, as well as cause tickets with that type to serve as 'leaf' nodes that stops the recursive dependency search.

AllDependsOn

Returns an array of RT::Ticket objects which this ticket (directly or indirectly) depends on; takes an optional 'Type' argument in the param hash, which will limit returned tickets to that type, as well as cause tickets with that type to serve as 'leaf' nodes that stops the recursive dependency search.

DependsOn

  This returns an RT::Links object which references all the tickets that this ticket depends on

Return links (RT::Links) to/from this object.

DIRECTION is either 'Base' or 'Target'.

TYPE is a type of links to return, it can be omitted to get links of any type.

FormatType

Takes a Type and returns a string that is more human readable.

Takes either a Target or a Base and returns a string of human friendly text.

Takes a paramhash of Type and one of Base or Target. Adds that link to this object.

Returns link id, message and exist flag.

Delete a link. takes a paramhash of Base, Target and Type. Either Base or Target must be null. The null value will be replaced with this ticket's id

LockForUpdate

In a database transaction, gains an exclusive lock on the row, to prevent race conditions. On SQLite, this is a "RESERVED" lock on the entire database.

_NewTransaction PARAMHASH

Private function to create a new RT::Transaction object for this ticket update

Transactions

  Returns an RT::Transactions object of all transactions on this record object

CustomFieldLookupType

Returns the path RT uses to figure out which custom fields apply to this object.

AddCustomFieldValue { Field => FIELD, Value => VALUE }

VALUE should be a string. FIELD can be any identifier of a CustomField supported by "LoadCustomFieldByIdentifier" method.

Adds VALUE as a value of CustomField FIELD. If this is a single-value custom field, deletes the old value. If VALUE is not a valid value for the custom field, returns (0, 'Error message' ) otherwise, returns ($id, 'Success Message') where $id is ID of created ObjectCustomFieldValue object.

DeleteCustomFieldValue { Field => FIELD, Value => VALUE }

Deletes VALUE as a value of CustomField FIELD.

VALUE can be a string, a CustomFieldValue or a ObjectCustomFieldValue.

If VALUE is not a valid value for the custom field, returns (0, 'Error message' ) otherwise, returns (1, 'Success Message')

FirstCustomFieldValue FIELD

Return the content of the first value of CustomField FIELD for this ticket Takes a field id or name

CustomFieldValuesAsString FIELD

Return the content of the CustomField FIELD for this ticket. If this is a multi-value custom field, values will be joined with newlines.

Takes a field id or name as the first argument

Takes an optional Separator => "," second and third argument if you want to join the values using something other than a newline

CustomFieldValues FIELD

Return a ObjectCustomFieldValues object of all values of the CustomField whose id or Name is FIELD for this record.

Returns an RT::ObjectCustomFieldValues object

LoadCustomFieldByIdentifier IDENTIFER

Find the custom field has id or name IDENTIFIER for this object.

If no valid field is found, returns an empty RT::CustomField object.

← Back to index