RT 5.0.5 Documentation

RT::Scrip

Go to latest version →

NAME

  RT::Scrip - an RT Scrip object

SYNOPSIS

  use RT::Scrip;

DESCRIPTION

METHODS

Create

Creates a new entry in the Scrips table. Takes a paramhash with:

        Queue                  => 0,
        Description            => undef,
        Template               => undef,
        ScripAction            => undef,
        ScripCondition         => undef,
        CustomPrepareCode      => undef,
        CustomCommitCode       => undef,
        CustomIsApplicableCode => undef,

Returns (retval, msg); retval is 0 for failure or scrip id. msg is a textual description of what happened.

Delete

Delete this object

AddToObject

Adds (applies) the current scrip to the provided queue (ObjectId).

Accepts a param hash of:

ObjectId

Queue name or id. 0 makes the scrip global.

Stage

Stage to run in. Valid stages are TransactionCreate or TransactionBatch. Defaults to TransactionCreate. As of RT 4.2, Disabled is no longer a stage.

Template

Name of global or queue-specific template for the scrip. Use 'Blank' for non-notification scrips.

SortOrder

Number indicating the relative order the scrip should run in.

Returns (val, message). If val is false, the message contains an error message.

RemoveFromObject

Removes the current scrip to the provided queue (ObjectId).

Accepts a param hash of:

ObjectId

Queue name or id. 0 makes the scrip global.

Returns (val, message). If val is false, the message contains an error message.

ActionObj

Retuns an RT::Action object with this Scrip's Action

ConditionObj

Retuns an RT::ScripCondition object with this Scrip's IsApplicable

LoadModules

Loads scrip's condition and action modules.

TemplateObj

Retuns an RT::Template object with this Scrip's Template

Stage

Takes TicketObj named argument and returns scrip's stage when added to ticket's queue.

FriendlyStage($Stage)

Helper function that returns a localized human-readable version of the $Stage argument.

Apply { TicketObj => undef, TransactionObj => undef}

This method instantiates the ScripCondition and ScripAction objects for a single execution of this scrip. it then calls the IsApplicable method of the ScripCondition. If that succeeds, it calls the Prepare method of the ScripAction. If that succeeds, it calls the Commit method of the ScripAction.

Usually, the ticket and transaction objects passed to this method should be loaded by the SuperUser role

IsApplicable

Calls the Condition object's IsApplicable method

Upon success, returns the applicable Transaction object. Otherwise, undef is returned.

If the Scrip is in the TransactionCreate Stage (the usual case), only test the associated Transaction object to see if it is applicable.

For Scrips in the TransactionBatch Stage, test all Transaction objects created during the Ticket object's lifetime, and returns the first one that is applicable.

Prepare

Calls the action object's prepare method

Commit

Calls the action object's commit method

_LoggerFilename

Helper method to generate the filename for a file logger for Scrip logging.

_AddFileLogger

Checks the LogScripsForUser config option to determine if Scrip logging is enabled for the current user and if so it calls RT::AddFileLogger to add a short lived file logger used for Scrip logging.

_RemoveFileLogger

Calls RT::RemoveFileLogger to remove a short lived file logger used for Scrip logging.

Passes RT::RemoveFileLogger a final log message that includes the date the log was created and the user it was created for.

ACLEquivalenceObjects

Having rights on any of the queues the scrip applies to is equivalent to having rights on the scrip.

CompileCheck

This routine compile-checks the custom prepare, commit, and is-applicable code to see if they are syntactically valid Perl. We eval them in a codeblock to avoid actually executing the code.

If one of the fields has a compile error, only the first is reported.

Returns an (ok, message) pair.

SetScripAction

SetScripCondition

SetTemplate

id

Returns the current value of id. (In the database, id is stored as 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).)

ScripCondition

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

SetScripCondition VALUE

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

ScripConditionObj

Returns the ScripCondition Object which has the id returned by ScripCondition

ScripAction

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

SetScripAction VALUE

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

ScripActionObj

Returns the ScripAction Object which has the id returned by ScripAction

CustomIsApplicableCode

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

SetCustomIsApplicableCode VALUE

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

CustomPrepareCode

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

SetCustomPrepareCode VALUE

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

CustomCommitCode

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

SetCustomCommitCode VALUE

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

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

Template

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

SetTemplate VALUE

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

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

← Back to index