Date format to set Due Date with scrip?

Hi,

The config setting ‘Requests should be due in:’ is not working, so I’m
trying to write a scrip to set the DueDate on ticket creation. I’m on RT
v3.6.2 and don’t want to upgrade just for this issue.

Following advice on the wiki I’ve got the following

Condition: On Create
Action: user defined
Template: Global template: blank

Custom action prep code: 1;
Custom action cleanup code:

use Date::Calc qw(:all);

($year,$month,$day) = Today([$gmt]);
($year2,$month2,$day2) = Add_Delta_Days($year,$month,$day,“7”);
$string = Date_to_Text($year2,$month2,$day2);
$lower = ISO_LC($string);
$self->TicketObj->SetDue($lower);

Due Date is not set though :frowning:

Running this on command line, $lower prints a date formatted as 'thu
27-may-2010’
I can hack around with the date format if someone can tell me what it
should be so that RT will accept it into the database (postgres).

Thanks

Steve

Dr Steven Platt
Bioinformatician
Health Protection Agency
Centre for Infections
London
www.hpa.org.uk/bioinformatics

The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of
the named addressee(s). It may not be disclosed to any other person
without the express authority of the HPA, or the intended
recipient, or both. If you are not the intended recipient, you must
not disclose, copy, distribute or retain this message or any part
of it. This footnote also confirms that this EMail has been swept
for computer viruses, but please re-sweep any attachments before
opening or saving. HTTP://www.HPA.org.uk

I think better would be this way:

my $Due = new RT::Date( $self->CurrentUser );
$Due->SetToNow;
$Due->AddDays( 7 );
$self->TicketObj->SetDue( Format =>, ‘ISO’, Value => $Due->ISO );

ChrisAm 20.05.2010 14:28, schrieb Steven Platt:

Hi,

The config setting �Requests should be due in:� is not working, so I�m
trying to write a scrip to set the DueDate on ticket creation. I�m on RT
v3.6.2 and don�t want to upgrade just for this issue.

Following advice on the wiki I�ve got the following

Condition: On Create

Action: user defined

Template: Global template: blank

Custom action prep code: 1;

Custom action cleanup code:

use Date::Calc qw(:all);

($year,$month,$day) = Today([$gmt]);

($year2,$month2,$day2) = Add_Delta_Days($year,$month,$day,“7”);

$string = Date_to_Text($year2,$month2,$day2);

$lower = ISO_LC($string);

$self->TicketObj->SetDue($lower);

Due Date is not set though L

Running this on command line, $lower prints a date formatted as �thu
27-may-2010�

I can hack around with the date format if someone can tell me what it
should be so that RT will accept it into the database (postgres).

Thanks

Steve

Dr Steven Platt

Bioinformatician

Health Protection Agency

Centre for Infections

London

__www.hpa.org.uk/bioinformatics http://www.hpa.org.uk/bioinformatics



The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of the
named addressee(s). It may not be disclosed to any other person without
the express authority of the HPA, or the intended recipient, or both. If
you are not the intended recipient, you must not disclose, copy,
distribute or retain this message or any part of it. This footnote also
confirms that this EMail has been swept for computer viruses, but please
re-sweep any attachments before opening or saving. HTTP://www.HPA.org.uk


Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Thanks Chris,

Unfortunately this gives me a ‘ticket could not be created due to an
internal error’ message. Tried it both as a regular and as a privileged
user.

The notification emails are generated but a search for the ticket number
gives ‘Could not load ticket NUMBER’. The ticket number is also
incremented.

teveFrom: Christian Loos [mailto:cloos@netcologne.de]
Sent: 20 May 2010 14:24
To: Steven Platt
Cc: rt-users@lists.bestpractical.com
Subject: Re: Date format to set Due Date with scrip?

I think better would be this way:

my $Due = new RT::Date( $self->CurrentUser );
$Due->SetToNow;
$Due->AddDays( 7 );
$self->TicketObj->SetDue( Format =>, ‘ISO’, Value => $Due->ISO );

Chris

Hi,

The config setting ‘Requests should be due in:’ is not working, so I’m
trying to write a scrip to set the DueDate on ticket creation. I’m on
RT
v3.6.2 and don’t want to upgrade just for this issue.

Following advice on the wiki I’ve got the following

Condition: On Create

Action: user defined

Template: Global template: blank

Custom action prep code: 1;

Custom action cleanup code:

use Date::Calc qw(:all);

($year,$month,$day) = Today([$gmt]);

($year2,$month2,$day2) = Add_Delta_Days($year,$month,$day,“7”);

$string = Date_to_Text($year2,$month2,$day2);

$lower = ISO_LC($string);

$self->TicketObj->SetDue($lower);

Due Date is not set though L

Running this on command line, $lower prints a date formatted as ‘thu
27-may-2010’

I can hack around with the date format if someone can tell me what it
should be so that RT will accept it into the database (postgres).

Thanks

Steve

Dr Steven Platt

Bioinformatician

Health Protection Agency

Centre for Infections

London

__www.hpa.org.uk/bioinformatics
http://www.hpa.org.uk/bioinformatics

The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of the
named addressee(s). It may not be disclosed to any other person
without
the express authority of the HPA, or the intended recipient, or both.
If
you are not the intended recipient, you must not disclose, copy,
distribute or retain this message or any part of it. This footnote
also
confirms that this EMail has been swept for computer viruses, but
please
re-sweep any attachments before opening or saving.
HTTP://www.HPA.org.uk


Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of
the named addressee(s). It may not be disclosed to any other person
without the express authority of the HPA, or the intended
recipient, or both. If you are not the intended recipient, you must
not disclose, copy, distribute or retain this message or any part
of it. This footnote also confirms that this EMail has been swept
for computer viruses, but please re-sweep any attachments before
opening or saving. HTTP://www.HPA.org.uk

You need in Custom action prep code:
return 1;
and at the end of my example also a:
return 1;

I added these but got the same result.From: Loos, Christian [mailto:CLoos@netcologne.de]
Sent: 20 May 2010 15:41
To: Steven Platt
Cc: rt-users@lists.bestpractical.com
Subject: AW: Date format to set Due Date with scrip?

You need in Custom action prep code:
return 1;
and at the end of my example also a:
return 1;

-----Ursprüngliche Nachricht-----
Von: Steven Platt [mailto:Steven.Platt@hpa.org.uk]
Gesendet: Donnerstag, 20. Mai 2010 15:44
An: Loos, Christian
Cc: rt-users@lists.bestpractical.com
Betreff: RE: Date format to set Due Date with scrip?

Thanks Chris,

Unfortunately this gives me a ‘ticket could not be created due to an
internal error’ message. Tried it both as a regular and as a
privileged
user.

The notification emails are generated but a search for the
ticket number
gives ‘Could not load ticket NUMBER’. The ticket number is also
incremented.

teve

-----Original Message-----
From: Christian Loos [mailto:cloos@netcologne.de]
Sent: 20 May 2010 14:24
To: Steven Platt
Cc: rt-users@lists.bestpractical.com
Subject: Re: Date format to set Due Date with scrip?

I think better would be this way:

my $Due = new RT::Date( $self->CurrentUser );
$Due->SetToNow;
$Due->AddDays( 7 );
$self->TicketObj->SetDue( Format =>, ‘ISO’, Value => $Due->ISO );


Chris

Am 20.05.2010 14:28, schrieb Steven Platt:

Hi,

The config setting ‘Requests should be due in:’ is not
working, so I’m
trying to write a scrip to set the DueDate on ticket
creation. I’m on
RT
v3.6.2 and don’t want to upgrade just for this issue.

Following advice on the wiki I’ve got the following

Condition: On Create

Action: user defined

Template: Global template: blank

Custom action prep code: 1;

Custom action cleanup code:

use Date::Calc qw(:all);

($year,$month,$day) = Today([$gmt]);

($year2,$month2,$day2) = Add_Delta_Days($year,$month,$day,“7”);

$string = Date_to_Text($year2,$month2,$day2);

$lower = ISO_LC($string);

$self->TicketObj->SetDue($lower);

Due Date is not set though L

Running this on command line, $lower prints a date formatted as ‘thu
27-may-2010’

I can hack around with the date format if someone can tell
me what it
should be so that RT will accept it into the database (postgres).

Thanks

Steve

Dr Steven Platt

Bioinformatician

Health Protection Agency

Centre for Infections

London

__www.hpa.org.uk/bioinformatics
http://www.hpa.org.uk/bioinformatics





**

The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and
use of the
named addressee(s). It may not be disclosed to any other person
without
the express authority of the HPA, or the intended
recipient, or both.
If
you are not the intended recipient, you must not disclose, copy,
distribute or retain this message or any part of it. This footnote
also
confirms that this EMail has been swept for computer viruses, but
please
re-sweep any attachments before opening or saving.
HTTP://www.HPA.org.uk




Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com




The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of
the named addressee(s). It may not be disclosed to any other person
without the express authority of the HPA, or the intended
recipient, or both. If you are not the intended recipient, you must
not disclose, copy, distribute or retain this message or any part
of it. This footnote also confirms that this EMail has been swept
for computer viruses, but please re-sweep any attachments before
opening or saving. HTTP://www.HPA.org.uk



The information contained in the EMail and any attachments is
confidential and intended solely and for the attention and use of
the named addressee(s). It may not be disclosed to any other person
without the express authority of the HPA, or the intended
recipient, or both. If you are not the intended recipient, you must
not disclose, copy, distribute or retain this message or any part
of it. This footnote also confirms that this EMail has been swept
for computer viruses, but please re-sweep any attachments before
opening or saving. HTTP://www.HPA.org.uk

What is in the log files?

Just checked my code in our development system and changed it.
Try this:

my $Due = new RT::Date( $self->CurrentUser );
$Due->SetToNow();
$Due->AddDays( 7 );
$self->TicketObj->SetDue( $Due->ISO );
return 1;

This is working on 3.8.6 and should work on 3.6.2 also.