[rt-users] Filling Dates fields with scrip
Cristiano da Costa
crsurf at gmail.com
Thu Feb 9 08:32:53 EST 2006
Hello Eric
I want to set a different SLA if user filled the field Start, bellow is my
code, but doesn´t work.
Can you give me some tip?
my $now = RT::Date->new($RT::SystemUser);
my $sla = RT::Date->new($RT::SystemUser);
$now->SetToNow;
$sla->SetToNow;
$sla->AddSeconds(+14400);
if ( $self->TicketObj->Starts eq '1970-01-01 00:00:00' ) {
$self->TicketObj->SetStarts( $now->ISO );
}
else {
$sla = $self->TicketObj->Starts;
$sla->AddSeconds(+14400);
}
if ( $self->TicketObj->Started eq '1970-01-01 00:00:00' ) {
$self->TicketObj->SetStarted( $now->ISO );
}
if ( $self->TicketObj->Due eq '1970-01-01 00:00:00' ) {
$self->TicketObj->SetDue( $sla->ISO );
}
return 1;
Sds
Cristiano
On 2/1/06, Schultz, Eric <ESchultz at corp.untd.com> wrote:
>
> I don't think the dates will ever be 'undef'. Instead, check for a
> default date. I believe that date is '1970-01-01 00:00:00' in our system.
>
> if ( $self->TicketObj->Started eq '1970-01-01 00:00:00' ) {
>
>
> ________________________________
>
> From: rt-users-bounces at lists.bestpractical.com [mailto:
> rt-users-bounces at lists.bestpractical.com] On Behalf Of Cristiano da Costa
> Sent: Wednesday, February 01, 2006 8:31 AM
> To: rt-users at lists.bestpractical.com
> Subject: [rt-users] Filling Dates fields with scrip
>
>
>
> Hello
>
> I want to fill the fields Starts, Started and Due after ticket
> creation, for this I´m using the code bellow on custom action in "on create"
> condition
>
>
> my $now = RT::Date->new($RT::SystemUser);
> my $sla = RT::Date->new($RT::SystemUser);
> $now->SetToNow;
> $sla->SetToNow;
> $sla->AddSeconds(+3600);
> $self->TicketObj->SetStarts( $now->ISO );
> $self->TicketObj->SetStarted( $now->ISO );
> $self->TicketObj->SetDue( $sla->ISO );
> return 1;
>
> This works, but if user that create tickts already fill these
> fields I don´t want to overwrite the user information, I tryed the following
> code in place of the code above, but doesn´t work.
>
> my $now = RT::Date->new($RT::SystemUser);
> my $sla = RT::Date->new($RT::SystemUser);
> $now->SetToNow;
> $sla->SetToNow;
> $sla->AddSeconds(+3600);
> if ( $self->TicketObj->Starts == undef ){
> $self->TicketObj->SetStarts( $now->ISO );
> }
> if ( $self->TicketObj->Started == undef ){
> $self->TicketObj->SetStarted( $now->ISO );
> }
> if ( $self->TicketObj->Due == undef ){
> $self->TicketObj->SetDue( $sla->ISO );
> }
> return 1;
>
> How can I test if user already fill these fields?
>
>
>
> Thanks
>
>
>
> Cristiano
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20060209/bcacb4a5/attachment.htm>
More information about the rt-users
mailing list