Ashish, Yep.
Kenn On 3/3/2009 12:21 PM, Potla, Ashish Bassaliel wrote: > Well, it worked for me! > Sorry.. keep tweaking it. > > hope you have return 1; in the cleanup code as well. > -Ashish > > ________________________________________ > From: Kenneth Crocker [kfcroc...@lbl.gov] > Sent: Wednesday, March 04, 2009 1:50 AM > To: Potla, Ashish Bassaliel > Cc: rt Users > Subject: Re: [rt-users] Scrip help needed on date formatting > > Ashish, > > > Tried that. No joy. > > > Kenn > LBNL > > On 3/3/2009 11:40 AM, Potla, Ashish Bassaliel wrote: >> Hey Ken, >> localize the variables as follows and try it out : >> >> my ( undef, undef, undef, $day, $mon, $year ) = localtime( time ); >> my $cf_value = sprintf( '%d/%02d/%02d', $year + 1900, $mon, $day ); >> >> -Ashish >> ________________________________________ >> From: rt-users-boun...@lists.bestpractical.com >> [rt-users-boun...@lists.bestpractical.com] On Behalf Of Kenneth Crocker >> [kfcroc...@lbl.gov] >> Sent: Wednesday, March 04, 2009 12:37 AM >> To: rt Users >> Subject: [rt-users] Scrip help needed on date formatting >> >> To all, >> >> >> I'm a newbie to perl. I've written a few simple scrips and they are >> working just fine. My problem lies in my lack of understanding as to why >> some code will work in a perl program, but not in a scrip. We have some >> good perl programmers here and they gave me some code to use to format a >> date I needed. >> Scenario: when a ticket has it's status changed to 'stalled', I want >> to >> update a Custom Field with the yyyy/mm/dd format for today's date. The >> code I was given for this is as follows: >> >> Custom Action Prep Code: >> # set the CF Work-Completed Date >> >> my $trans = $self->TransactionObj; >> my $ticket = $self->TicketObj; >> my $cf_obj = RT::CustomField->new($RT::SystemUser); >> my $cf_name = "Stalled Date"; >> ( undef, undef, undef, $day, $mon, $year ) = localtime( time ); >> $cf_value = sprintf( '%d/%02d/%02d', $year + 1900, $mon, $day ); >> >> $cf_obj->LoadByName(Name=>$cf_name); >> $RT::Logger->debug("Loaded\$cf_obj->Name = ". $cf_obj->Name() ."\n"); >> $ticket->AddCustomFieldValue(Field=>$cf_obj, Value=>$cf_value, >> RecordTransaction=>0); >> >> return 1; >> >> I get nothing. If I change the value of $cf_value to simply >> (localtime), I get the full-fledged format of "Thu Feb 26 14:54:33 2009". >> So, I know the condition works and the function of update the Custom >> Field works. I just cannot get the code I was given to format the date >> to work as a scrip. >> Anyone have some experience with this and willing to help? >> >> >> Kenn >> LBNL >> >> _______________________________________________ >> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users >> >> Community help: http://wiki.bestpractical.com >> Commercial support: sa...@bestpractical.com >> >> >> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. >> Buy a copy at http://rtbook.bestpractical.com >> > > _______________________________________________ http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users Community help: http://wiki.bestpractical.com Commercial support: sa...@bestpractical.com Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com