Approval - Custom Action Scrip to create Approval Tickets

I need to create multiple approval tickets based on content in custom
fields of the parent ticket. Tickets are being created based on the
custom field content, approvers are being specified from another custom
field. If multiple approvers are specified, multiple tickets are
created.

I’ve managed to get almost everything to work using the following in a
custom action scrip:

my ($child_id, $child_transobj, $errormsg ) =

  $child_ticket->Create( 

  Queue => $queue_name , 

  Subject => "Approval for ticket: " . $ticket->id . " - " .

$ticket->Subject,

  Cc => $override_approver,

  RefersTo => $ticket->id , 

  DependedOnBy => $ticket->id , 

  Type => "approval" , 

  Reqestor => $req_addr, 

  Owner => $approver,

  AdminCc => $approver,

);

I still haven’t figured out how to add content, set a due date 2 days
from now, or set a custom field.

Content:

I would like the initial content of the ticket to be the following:

Approval for $ticket->FirstCustomFieldValue(‘UserDisplayName’)

To submit your response via e-mail. To do so, reply to this message
with one of the following responses in the

body of the message:

To approve:

 Status: Resolved

To reject:

 Status: Rejected

To view the original request, follow this link:
RT->Config->Get(‘WebURL’)}Ticket/Display.html?id=$ticket->id

Additional information is below:

$ticket->Transactions->First->Content()

I have tried adding both of the following lines into the ticket
creation, but the content is not added. That being said, there are also
no errors reported:

  Text => "The Text Field",

  Content => "The Content Field",

Custom Field:

My custom field is ApprovalType. I have tried the following (based on
what is used in templates):

CF-ApprovalType => “User”

I get the following error

[Tue Mar 9 16:22:27 2010] [error]: Scrip 74 Prepare failed: Bareword
"CF" not allowed while “strict subs” in use at (eval 3132) line 19.
(/usr/lib/rt/RT/Action/UserDefined.pm:64)

Due Date:

The template that I’m basing this on uses the following line to set the
date:

Due: {time + 86400}

I’m not sure how to set that time within the custom action of a scrip.

I tried the following & it didn’t work:

Due => time + 86400

The following error is returned:

[Tue Mar 9 16:30:10 2010] [error]: Scrip 74 Prepare failed: Day '68’
out of range 1…31 at /usr/lib/rt/RT/Date.pm line 966

Anyone have any words of wisdom?

Jennifer Koermer

Assistant Director of Information Technology

PRG

Production Resource Group
7777 West Side Avenue, North Bergen, NJ 07047
201-758-4349 phone
201-868-7195 fax

201-232-7691 cell
jkoermer@prg.com mailto:jkoermer@prg.com
www.prg.com http://www.prg.com/

I need to create multiple approval tickets based on content in custom fields of the parent
ticket. Tickets are being created based on the custom field content, approvers are being
specified from another custom field. If multiple approvers are specified, multiple tickets
are created.

Since you seem confident enough to turn the standard CreateTickets
template into a scrip action, you may find it useful to read the
documentation and code in lib/RT/Action/CreateTickets.pm for examples
of doing what you want to do.

-kevin