Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Potla, Ashish Bassaliel
Hi,
Can you give some info about the CF you are using?
What is the type and validation settings on it?

-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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Potla, Ashish Bassaliel
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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Kenneth Crocker
Ashish,

Just Enter one value. That's it. No validation settings. Although 
I've thought about using (?#Date 
/mm/dd)^(([1-2][0-9][0-9][0-9])\/(0[1-9]|1[0-2])\/(0[1-9]|[1-2][0-9]|3[0-1]))?$
 
as a validation setting.


Kenn
LBNL

On 3/3/2009 11:21 AM, Potla, Ashish Bassaliel wrote:
 Hi,
 Can you give some info about the CF you are using?
 What is the type and validation settings on it?
 
 -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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Kenneth Crocker
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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Potla, Ashish Bassaliel
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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Kenneth Crocker
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 /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


Re: [rt-users] Scrip help needed on date formatting

2009-03-03 Thread Kenneth Crocker
Ashish,


Sorry. I'm such a dummy. I made your changes and when I tested it, I 
forgot to change a condition back to original (I was testing some other 
stuff). It now works, like you said it would. It was the missing my. 
THANKS!!

Kenn
LBNL




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 /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