We want to make some statistics regarding our customers way of creating tickets: via email or via RT web portal. We searched for an automatic way to extract this information but did not find one.
The usernames of our customers have the same value as their email address, so the Requestor has the same value regardless which method they used to create a ticket; therefore we cannot use Requestor as discriminator.
Then we thought we found a solution when we added a custom field ''Created via RT GUI" with single value âYesâ which would have values:
- âno valueâ when ticket is created via email
- âYesâ when ticket is created via RT GUI
The problem is that we process tickets created by Customers (via email) using RT GUI (i.e. we follow the workflow until they are closed), and any web modification on the ticket will override the custom field âno valueâ with âYesâ and weâre back to square one. Of course we could add options like âYesâ or âNoâ but the point is to make this process automatic and avoid relying on user input on this which would be error prone.
Please let me know if you know about other options to automate this detection.
Thanks
If you look at the headers for transactions you can see X-RT-Interface
header which will say Web
, Rest
or Email
. So you can look at the create transaction (first one) and see how it was created. You could also have a scrip that runs On Create
and checks the header and sets a custom field on the ticket for how it was created
Hi,
Thanks for your quick answer.
We like the last idea, which is to create a scrip which sets a custom field value on create ticket, based on value of header X-RT-Interface. In some pseudo-code, this would be:
if ( = âWebâ)
then = âCreated via Webâ
Please correct me if the scrip parameters are not the following (we are using RT 5.0.1):
Basics:
- Condition: On Create
- Action: User Defined
- Template: Blank
- Applies to: Global
User Defined Conditions and results:
- Custom condition: empty
- Custom action preparation code: return 1;
- Custom action commit code: ???
As you can see Iâm not experienced with RT scrip code in Perl, can you please provide more details on how to write this code?
Looks like the web site miss-formatted my âpseudo-codeâ because I used some illegal characters. What I wrote was something like:
if (transaction header X-RT-Interface = âWebâ) then (My Custom Field Value = âCreated via Webâ)
$self->TransactionObj->Attachments->First->GetHeader('X-RT-Interface')
Gets you the header and then you can set a CF via $self->TicketObj->AddCustomFieldValue(Field => 'some name', Value => 'Some Value' );
Thanks again, it worked.
In RT I defined a custom field âCreated via RT GUIâ with two options (Yes and No) and default value Yes. When ticket is created by web, the custom field will take the default value Yes.
Then I added this scrip for tickets created by Email:
my $header = $self->TransactionObj->Attachments->First->GetHeader(âX-RT-Interfaceâ);
if ($header eq âEmailâ) {
$self->TicketObj->AddCustomFieldValue(Field => âCreated via RT GUIâ, Value => âNoâ );
}
return 1;
The result is that the custom field now contains the correct value Yes or No without user intervention.
1 Like