[rt-users] automatically set due date and priority based on customfield

Eric Horne eric.horne at teradyne.com
Fri Dec 16 15:34:10 EST 2005


I haven't actually tested this code, but I suspect you could do like his:

Condition: User Defined
Action: User Defined
Template: Blank

Condition:
($self->TransactionObj->Type eq "CustomField") &&
($self->TransactionObj->Field eq 00);
# replace 00 above with the CustomField NUMBER id.

Action:
my $date = new RT:Date();
my $val = $self->TicketObj->FirstCustomFieldValue("CustomField");
$date->SetToNow();

if ($val eq "1") {
	$date->AddSeconds(3600);
}
elsif ($val eq "2") {
# and so on
}

# Why is there no SetDue function?
# There may be a more efficient way to do this.
$self->TicketObj->_Set(Field => "Due", Value => $date->AsString);
return 1;


Matt Nichols wrote:
> Hi Eric,
> 
> I have created a custom field 'severity' where users can select a
> severity level (for example severity levels 1-4) when creating a new
> ticket. I would like to automatically assign predefined due dates and
> priority levels based on the selection from the 'severity' field.
> 
> For example:
> 
> Severity 1 - Due 1 hour from now - Priority W
> Severity 2 - Due 4 hours from now - Priority X
> Severity 3 - Due 8 hours from now - Priority Y
> Severity 4 - Due 24 hours from now - Priority Z
> 
> Thanks for the example code.
> 
> -Matt
> 
> -----Original Message-----
> From: rt-users-bounces at lists.bestpractical.com
> [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Eric
> Horne
> Sent: Friday, December 16, 2005 1:52 PM
> To: rt-users
> Subject: Re: [rt-users] automatically set due date and priority based on
> customfield
> 
> I've set the due date based on a due date embedded into the request. If 
> the user says "DateDue: Feb 28, 2006 2:00" it'll set the duedate to that
> 
> specified date.
> 
> It's not exactly what you are asking for, but maybe it helps get you 
> started. I think there is some date manipulation you can perform within 
> WebRT via the RT::Date class.
> 
> -eric
> 
> Condition: On Create
> Template: Blank
> Action:
> 
> my $AttachObj = $self->TransactionObj->Attachments->First;
> # go out if content is not text!
> unless( $AttachObj->ContentType =~ /^text/ ) {
>       return 1;
> }
> 
> my $content = $AttachObj->Content;
> 
> if ($content =~ m/^\QDate-Due:\E\s*([-0-9\:\s]+[0-9])\s*$/m) {
>        $self->TicketObj->_Set(Field => "Due", Value => $1);
> }
> 
> 
> 
> Matt Nichols wrote:
> 
>>Hello,
>>
>>I'd like to automatically set the due date and priority of new tickets
> 
> 
>>based on a users selection of the custom field 'severity'. The
> 
> creation 
> 
>>of the custom field 'severity' was the easy part. My understanding is 
>>that the automatic setting of due date and priority based on this
> 
> custom 
> 
>>field can be accomplished with a scrip. Has anyone done anything
> 
> similar 
> 
>>to this?
>>
>>Thanks.
>>
>>-Matt
>>_______________________________________________
>>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>
>>Be sure to check out the RT Wiki at http://wiki.bestpractical.com
>>
>>Download a free sample chapter of RT Essentials from O'Reilly Media at
> 
> 
>>http://rtbook.bestpractical.com
>>
>>WE'RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
>>San Francisco - Find out more at 
>>http://bestpractical.com/services/training.html
> 
> 
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
> 
> Download a free sample chapter of RT Essentials from O'Reilly Media at
> http://rtbook.bestpractical.com
> 
> WE'RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
> San Francisco - Find out more at
> http://bestpractical.com/services/training.html
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
> 
> Download a free sample chapter of RT Essentials from O'Reilly Media at http://rtbook.bestpractical.com
> 
> WE'RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
> San Francisco - Find out more at http://bestpractical.com/services/training.html




More information about the rt-users mailing list