Auto-Creating Child Tickets

I’ve followed the method laid out in the wiki for automated approvals in order
to create child tickets.

I’ve created the following template:
===Create-Ticket: Child
Depended-on-by: TOP
Status: new
Queue: TechOps
Type: ticket
Refers-To: {$Tickets{‘TOP’}->Id()}
Content: This is a child ticket
ENDOFCONTENT

And a scrip which makes use of it with the following settings:
Condition: On Create
Action: Create Tickets
Template: CreateChild (the template above)

Custom Condition:
unless (
( $self->TransactionObj->Type eq “CustomField”
&& $self->TransactionObj->Field == 9 )
|| $self->TransactionObj->Type eq “Create”
) {
return 0;
}

Custom action preparation code:
return 0 unless $self->TicketObj->FirstCustomFieldValue(‘CustomerCare Ticket
Type’) =~ /Provisioning/i;

Custom action cleanup code:
return 1;

What I am looking for it to do is create the child tickets only if the initial
type of ticket is set to Provisioning. However, the child ticket is created
regardless of the ticket type. I’d also like it to not create a child if the
ticket comes in via email.

Can someone point out the problems with my set-up that is causing it to break?

Thanks
Mathew
Keep up with me and what I’m up to: http://theillien.blogspot.com

Mathew Snyder wrote:

I’ve followed the method laid out in the wiki for automated approvals in order
to create child tickets.

I’ve created the following template:
===Create-Ticket: Child
Subject: {$Tickets{‘TOP’}->Subject} - Child
Depended-on-by: TOP
Status: new
Queue: TechOps
Type: ticket
Refers-To: {$Tickets{‘TOP’}->Id()}
Content: This is a child ticket
ENDOFCONTENT

And a scrip which makes use of it with the following settings:
Condition: On Create
Action: Create Tickets
Template: CreateChild (the template above)

Custom Condition:
unless (
( $self->TransactionObj->Type eq “CustomField”
&& $self->TransactionObj->Field == 9 )
|| $self->TransactionObj->Type eq “Create”
) {
return 0;
}

Custom action preparation code:
return 0 unless $self->TicketObj->FirstCustomFieldValue(‘CustomerCare Ticket
Type’) =~ /Provisioning/i;

Custom action cleanup code:
return 1;

What I am looking for it to do is create the child tickets only if the initial
type of ticket is set to Provisioning. However, the child ticket is created
regardless of the ticket type. I’d also like it to not create a child if the
ticket comes in via email.

Can someone point out the problems with my set-up that is causing it to break?

Thanks
Mathew

I’ve changed the logic to:
Custom condition:
if (($self->TransactionObj->Type eq “CustomField” &&
$self->TransactionObj->Field == 9 &&
$self->TicketObj->FirstCustomFieldValue(‘Ticket Type’)) eq “Provisioning”)){
return 1;
} else {
return 0;
}

Custom action preparation code:
return 1;

Custom action cleanup code:
empty

But still get child tickets created regardless of the value of the “Ticket Type” CF.

Keep up with me and what I’m up to: http://theillien.blogspot.com

IIRC, Custom fields are set in a different transaction than the ticket
creation. Perhaps this is tripping you up?

Mathew Snyder wrote:

That wouldn’t be it. I set custom fields in other scrips.

Keep up with me and what I’m up to: http://theillien.blogspot.com

Drew Barnes wrote:

Ah. I think I see it here:

I’ve created the following template:
===Create-Ticket: Child
Depended-on-by: TOP
Status: new
Queue: TechOps
Type: ticket
Refers-To: {$Tickets{‘TOP’}->Id()}
Content: This is a child ticket
ENDOFCONTENT

And a scrip which makes use of it with the following settings:
Condition: On Create
Action: Create Tickets
Template: CreateChild (the template above)

Try setting the scrip to:
Condition: User Defined
Action: User Defined (maybe… Create Tickets may work)
Template: CreateChild

Also, throw some debug statements in to make sure you are getting the
expected values.

Mathew Snyder wrote:

That was the problem. Thanks. I guess sometimes it just takes a second
pair of eyes to find what might usually be an obvious mistake.

Keep up with my goings on at http://theillien.blogspot.com

Drew Barnes wrote: