I would like to update Starts date when user takes a ticket but only for the first time. During ticket creation Starts date and Created date is the same, so it is one of my condition. I don’t know how to control sql fields from Ticket table (there are starts and created date which are visible in ticket properties).
Conditions:
my $tck = $Tickets;
my $txn = $self->TransactionObj;
return 0 unless $txn->Type eq “Set”;
return 0 unless $txn->Field eq “Owner”;
return 0 unless $txn->OldValue == $RT::Nobody->id;
return 0 unless $txn->NewValue == $txn->Creator;
return 0 unless $tck->Created ne $tck->Starts;
return 1;
Commit code:
$self->TicketObj->AddCustomFieldValue(
Field => ‘Reakcja’,
Value => $self->TransactionObj->Created
);
$Tickets->Starts => $Tickets->Created;
return 1;
EDIT:
I did some modification and my condition works good now, but I still have a problem with action code which should modify Ticket’s starts date.
$self->TicketObj->SetStarts (
Format => ‘ISO’,
Value => ‘20180101 11:11:11’
);
Scrip runs properly, but history of ticket shows below lines. If this is a problem with Value format or I simply can’t modify Starts date and it will be overwritten permanently by created date (created date for this ticket is 29/01/2018 08:09:00).
Mon Jan 29 12:48:29 2018 The RT System itself - Starts changed from Mon Jan 29 08:09:00 2018 to Not set
Mon Jan 29 12:48:29 2018 The RT System itself - Starts changed from Not set to Mon Jan 29 08:09:00 2018