[rt-users] Setting Due Dates from E-mail and writing Comments to transaction history from Custom Scrips

Dave Fitches david.fitches at unimelb.edu.au
Tue Aug 20 21:43:15 EDT 2013


Hey Landon,

Thanks a heap for the feedback.

Problem 1 is now FIXED thanks to you!

Final code for the ExtractCustomFieldValues template for those who are interested, ended up being:

                # Set the jobs Due Date from E-mail Body
|Body|(?<=Open Date:    ).*|my $Due = new RT::Date( $self->CurrentUser ); $Due->Set(Format => "unknown", Value => $value); $Due->AddDays( -1 ); $self->TicketObj->SetDue( $Due->ISO );|q|

Though I did then have some interesting hic-cups with it arguing with the SLA mod...
When the E-mail Value Extract was picking up the date, the SLA mod was promptly altering it. Ended up having to remove the default SLA, manually define the SLA for all other queues (not a BAD thing) and then create a new scrip for on CREATE to make it set the STARTS date otherwise the Priority Escalate process wouldn't work....<!!>

As for Problem 2 - your suggestion sadly didn't work.

Dave Fitches
Security Software Administrator | Security Systems | Property and Campus Services
BN203, 213-215 Grattan Street
The University of Melbourne, Victoria 3010, Australia
T +61 3 8344 9232 | M +61 411 811 525 | F +61 3 9349 5175 | dfitches at unimelb.edu.au<mailto:dfitches at unimelb.edu.au> | securitysystems.unimelb.edu.au<http://securitysystems.unimelb.edu.au/>
[cid:image001.png at 01CDDD27.F59750D0]
This email and any attachments may contain personal information or information that is otherwise confidential or the subject of copyright. Any use, disclosure or copying of any part of it is prohibited. The University does not warrant that this email or any attachments are free from viruses or defects. Please check any attachments for viruses and defects before opening them. If this email is received in error please delete it and notify us by return email. And I'm only using this signature template because I'm told I must conform. Personally I liked my old one better - but that's life! ;)

From: Landon [mailto:landonstewart at gmail.com]
Sent: Tuesday, 20 August 2013 3:35 AM
To: Dave Fitches
Cc: rt-users at lists.bestpractical.com
Subject: Re: [rt-users] Setting Due Dates from E-mail and writing Comments to transaction history from Custom Scrips

On 18 August 2013 22:05, Dave Fitches <david.fitches at unimelb.edu.au<mailto:david.fitches at unimelb.edu.au>> wrote:
My template goes something like this:

# Set the jobs Due Date from E-mail Body
|Body|(?<=Open Date:    ).*|my $due_date = $value; $due_date->Set(Format => "ISO", Value => $value); $self->TicketObj->SetDue( $due_date->ISO );|q|

This does NOT work for me... :(
Instead I get: " [Mon Aug 19 04:47:17 2013] [error]: Can't call method "Set" on an undefined value at (eval 1293) line 1. " in my logs...

$due_date needs to be an RT::Date object in order to use set or ISO.  Is it?

ie:
$due_date = new RT::Date( $self->CurrentUser );
$due_date->Set(Format => "ISO", Value => $value);
$self->TicketObj->SetDue( $due_date->ISO );

Since your dates are not in ISO format I'd probably recommend using Format => 'unknown' to set the RT::Date figure it out.  It takes a few extra cycles but provides flexibility when needed.

I use this:
my $Due = new RT::Date( $self->CurrentUser );
$Due->Set( Format => 'unknown', Value => 'now + 24 hours');
$ticket->SetDue($Due->ISO);

Problem #2: Writing a comment to the transaction history
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While it shows up in my main HISTORY display, my DISPLAY history is masked to only show comments and correspondence, so I'd like a single comment line there to make seeing whats happened easier...
                                CUSTOM ACTION CLEANUP CODE:
                                                $self->TicketObj->Comment(Content =>"Notification sent to original requestor that their order has been processed."
);
I suspect the issue is in the cleanup code.... But it LOOKS correct! (to me - but I'm a n00b apparently!)
If I'm understanding you correctly and if memory serves me I *think* you can just add RecordTransaction => 1 to the end of this and it'll do what you want.  I know this works for AddCustomFieldValue() but I'm not 100% sure if it works for Comment().  Worth a try though.

$self->TicketObj->Comment(Content =>"Notification sent to original requestor that their order has been processed.", RecordTransaction => 1);

--
Landon Stewart <LandonStewart at Gmail.com<mailto:LandonStewart at Gmail.com>>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130821/fdc91bc7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 17944 bytes
Desc: image001.png
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130821/fdc91bc7/attachment.png>


More information about the rt-users mailing list