Scrip condition on transaction custom field

Hi everyone,

I have an issue which i can’t get resolved without further help by
anyone more experienced RT user/admin.

I want to have a special trigger which can be activated during the
resolving stage on a ticket in order to decide whether an appropriate
message will be sent to the ticket requester or not. Feedback mails to
requester are generally deactivated. The idea is that RT users then can
resolve tickets as normal but if they want that a feedback mail shall be
send they can set the transaction CF to ‘yes’ and do so explicitly.

For this, I’ve crated a transaction custom field ‘feedback’, enabled it
for my queue, with selectable values ‘yes’ and ‘no’. I’ve then created a
batch scrip (from what I’ve learned it must be batch if transaction CFs
shall be parsed) which checks for two conditions: 1) ticket was resolved
and 2) transaction CF ‘feedback’ is set to ‘yes’. The first part works
perfectly fine, but i don’t get the second part working. I’ve tried
dozens of different ways two access transactions CFs, but it just wont
work.

So here are some methods which i tried unsuccessfully so far:

return 0 unless $self->TicketObj->FirstCustomFieldValue(‘feedback’) eq
’yes’; # only on ticket CFs?
2)
my $cfs=$txn->CustomFieldValues;
my $cf = $cfs->LimitToCustomField(‘feedback’);
my $response = $cf->Next;
return 0 unless $response->Content eq ‘yes’;
3)
my $cfvs=$txn->CustomFieldValues;
my $feedback = 0;
while (my $cfv = $cfvs->Next)
{
my $cfObj = $cfv->CustomFieldObj;
my $cf_name = $cfObj->Name;
my $cfv_name = $cfv->Name;
if ($cf_name eq ‘feedback’ && $cfv_name eq ‘yes’) {
$feedback = 1;
}
}
return 0 if $feedback == 0;

So my question is: how do i access the transaction CF of my last
transaction (i.e. a resolve transaction = comment + status change to
resolve) in a scrip condition?

I found the documentation on this specific topic (transaction CFs, not
tiecket CFs) quite incomplete and hope some of you will be able to help me.

Many thank sin advance!

  • Sebastian

Sebastian Jünemann
CeBiTec - Center for Biotechnology
Bielefeld University, D-33594 Bielefeld, Germany
Office: V6-147 – Phone: +49-(0)521-106-4827
eMail: jueneman@CeBiTec.Uni-Bielefeld.de

Hi everyone,

OK - meanwhile i got this issue solved but still have some questions,
especially about some strange behavior of RT.

The following scenario: I’m resolving a ticket via GUI and setting the
custom field for this transaction (“FeedbackOnResolve”) to “yes”. If I
also leaving a comment (i.e. writing something in the text field) this
triggers two transactions: first the comment transaction, then the
status change transaction 9from open to resolved).

  1. it should be better commented that $self->TransactionObj in a batch
    scrip (condition) returns the first triggering/applicable
    transaction object. This can get really awkward in the scrip if you
    write several tests and when not everything fits, the the first
    applicable transaction might not be really the first transaction in
    this cascade. So there is limited reliance on this behavior.

  2. transaction custom fields (CFS) are somehow attached to ‘comment’ (or
    correspondence) transactions only. So in order get TCFs working you are
    forced to fill out the text form in order to actually trigger a
    comment/correspondence transaction to which this CF will be attached.
    This also means that if you’re searching for specific values on TCFs you
    need to parse through the appropriate transaction type, i.e.
    comment/correspondence.

Or is there another way to trigger TCFs in scrips for other transaction
types as e.g. ‘Status’ or ‘Set’? And why do TCFs are not handled like
ticket CFs (i.e. triggering an own ‘CustomField’ typed transaction)?

The whole documentary is more or less completely written for ticket CFs,
which are handled totally different.

  1. if anyone is interested the solution for my problem is the following:

my $resolved = 0;
my $feedback = 0;
my $trans_list = $self->TicketObj->TransactionBatch;
my $trans;
foreach my $trans (@$trans_list) {
my $type = $trans->Type;
my $field = $trans->Field;
if ($type eq “Status” || ( $type eq “Set” && $field eq “Status”)){
$resolved = 1 if ($trans->NewValue eq “resolved”);
} elsif ($type eq “Comment”) {
my $cfvs = $trans->CustomFieldValues(“FeedbackOnResolve”);
if (my $value = $cfvs->Next()) {
$feedback = 1 if ($value->Content() eq “yes”);
}
}
}
return 0 unless $resolved && $feedback;
return 1;

  • SebastianOn 02/17/2016 08:36 AM, Sebastian Juenemann wrote:

Hi everyone,

I have an issue which i can’t get resolved without further help by
anyone more experienced RT user/admin.

I want to have a special trigger which can be activated during the
resolving stage on a ticket in order to decide whether an appropriate
message will be sent to the ticket requester or not. Feedback mails to
requester are generally deactivated. The idea is that RT users then can
resolve tickets as normal but if they want that a feedback mail shall be
send they can set the transaction CF to ‘yes’ and do so explicitly.

For this, I’ve crated a transaction custom field ‘feedback’, enabled it
for my queue, with selectable values ‘yes’ and ‘no’. I’ve then created a
batch scrip (from what I’ve learned it must be batch if transaction CFs
shall be parsed) which checks for two conditions: 1) ticket was resolved
and 2) transaction CF ‘feedback’ is set to ‘yes’. The first part works
perfectly fine, but i don’t get the second part working. I’ve tried
dozens of different ways two access transactions CFs, but it just wont
work.

So here are some methods which i tried unsuccessfully so far:

return 0 unless $self->TicketObj->FirstCustomFieldValue(‘feedback’) eq
’yes’; # only on ticket CFs?
2)
my $cfs=$txn->CustomFieldValues;
my $cf = $cfs->LimitToCustomField(‘feedback’);
my $response = $cf->Next;
return 0 unless $response->Content eq ‘yes’;
3)
my $cfvs=$txn->CustomFieldValues;
my $feedback = 0;
while (my $cfv = $cfvs->Next)
{
my $cfObj = $cfv->CustomFieldObj;
my $cf_name = $cfObj->Name;
my $cfv_name = $cfv->Name;
if ($cf_name eq ‘feedback’ && $cfv_name eq ‘yes’) {
$feedback = 1;
}
}
return 0 if $feedback == 0;

So my question is: how do i access the transaction CF of my last
transaction (i.e. a resolve transaction = comment + status change to
resolve) in a scrip condition?

I found the documentation on this specific topic (transaction CFs, not
tiecket CFs) quite incomplete and hope some of you will be able to help me.

Many thank sin advance!

  • Sebastian

Sebastian Jünemann
CeBiTec - Center for Biotechnology
Bielefeld University, D-33594 Bielefeld, Germany
Office: V6-147 – Phone: +49-(0)521-106-4827
eMail: jueneman@CeBiTec.Uni-Bielefeld.de