this is my first attempt at writing a custom condition for a scrip and I’m struggling to make it work. I started here https://rt-wiki.bestpractical.com/wiki/WriteCustomCondition and based on this:
# get ticket object my $ticket = $self->TicketObj; # don't do anything if ticket is resolved return 0 if $ticket->Status eq 'resolved'; # otherwise run scrip action return 1;
# get ticket object my $ticket = $self->TicketObj; # run scrip if Work Item is already set return 1 if $ticket->CustomFieldValue(Field =>'Work Item Number') ne undef; # get transaction object my $transaction = $self->TransactionObj; # run scrip if Work Item is being set return 1 if $transaction->CustomFieldValue(Field =>'Work Item Number') ne undef; # otherwise do nothing return 0;
For the scrip I have the following set:
Condition: User defined (as above)
Action: Open Tickets
I put the above together from a bunch of examples on the rt-wiki but I have never written even a lick of perl before so I feel like I am essentially flailing about here.
I have a custom field “Work Item Number” that is always empty when a ticket is created. When a work item number is allocated to the ticket we want that ticket to change from new to open, and not before. Tickets with a value in the “Work item number” custom field should be set to ‘open’ so I want the scrip to fire when either the ticket already has a value or a transaction sets a value.
It doesn’t matter what value I set to the CF the status of the ticket never changes.
I tried changing the action to the following custom action:
# get ticket object my $ticket = $self->TicketObj; # set ticket to open TicketObj->SetStatus( 'open' ); return 1;
but still no joy.
Can anyone suggest where I am going wrong? Is the logic broken? Or perhaps some suggested reading on how to learn to code this?