[rt-users] Filling Dates fields with scrip

Schultz, Eric ESchultz at corp.untd.com
Wed Feb 1 11:46:12 EST 2006


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 




More information about the rt-users mailing list