State#

NAME#

Kernel::System::State - state lib

DESCRIPTION#

All ticket state functions.

PUBLIC INTERFACE#

new()#

create an object

my $StateObject = $Kernel::OM->Get('Kernel::System::State');

StateAdd()#

add new states

my $ID = $StateObject->StateAdd(
    Name    => 'New State',
    Comment => 'some comment',
    ValidID => 1,
    TypeID  => 1,
    Color   => '#FF8A25',
    UserID  => 123,
);

StateGet()#

get state attributes

my %State = $StateObject->StateGet(
    Name  => 'New State',
);

my %State = $StateObject->StateGet(
    ID    => 123,
);

returns

my %State = (
    Name       => "new",
    ID         => 1,
    TypeName   => "new",
    TypeID     => 1,
    ValidID    => 1,
    Comment    => "New ticket created by customer.",
    Color      => "#FF8A25",
    CreateTime => "2010-11-29 11:04:04",
    ChangeTime => "2010-11-29 11:04:04",
);

StateUpdate()#

update state attributes

$StateObject->StateUpdate(
    ID      => 123,
    Name    => 'New State',
    Comment => 'some comment',
    ValidID => 1,
    TypeID  => 1,
    Color   => '#FF8A25',
    UserID  => 123,
);

StateGetStatesByType()#

get list of states for a type or a list of state types.

Get all states with state type open and new: (available: new, open, closed, pending reminder, pending auto, removed, merged)

my @List = $StateObject->StateGetStatesByType(
    StateType => ['open', 'new'],
    Result    => 'ID',              # HASH|ID|Name
);

Get all state types used by config option named like Ticket::ViewableStateType for “Viewable” state types.

my %List = $StateObject->StateGetStatesByType(
    Type   => 'Viewable',
    Result => 'HASH',               # HASH|ID|Name
);

StateList()#

get state list as a hash of ID, Name pairs

my %List = $StateObject->StateList(
    UserID => 123,
);

my %List = $StateObject->StateList(
    UserID => 123,
    Valid  => 1, # is default
);

my %List = $StateObject->StateList(
    UserID => 123,
    Valid  => 0,
);

returns

my %List = (
    1 => "new",
    2 => "closed successful",
    3 => "closed unsuccessful",
    4 => "open",
    5 => "removed",
    6 => "pending reminder",
    7 => "pending auto close+",
    8 => "pending auto close-",
    9 => "merged",
);

StateLookup()#

returns the id or the name of a state

my $StateID = $StateObject->StateLookup(
    State => 'closed successful',
);

my $State = $StateObject->StateLookup(
    StateID => 2,
);

StateTypeList()#

get state type list as a hash of ID, Name pairs

my %ListType = $StateObject->StateTypeList(
    UserID => 123,
);

returns

my %ListType = (
    1 => "new",
    2 => "open",
    3 => "closed",
    4 => "pending reminder",
    5 => "pending auto",
    6 => "removed",
    7 => "merged",
);

StateTypeLookup()#

returns the id or the name of a state type

my $StateTypeID = $StateObject->StateTypeLookup(
    StateType => 'pending auto',
);

or

my $StateType = $StateObject->StateTypeLookup(
    StateTypeID => 1,
);