We have recently hired an outside company to be our "Tier-One" tech support. Every call they log sends us an email. We are filtering out the "Escalation" tickets and having those one added to our Helpdesk RT queue (Thanks to procmail). Now we need to parse the subject line of these Escalated tickets and pull out the "Tier-One" Call ID # and have that dumped into a custom field. My perl skills are limited to none, so I have tried to put together a few other scrips that I user and/or found to create one, but it is not working as I expect (it seems like it does nothing at all, either never applied, or is applied, but does not fill in the CustomField)... so I come to the exports to look over my work....<br>
<br>Every one of the incoming "Escalation" emails will have a set FROM and SUBJECT field....<br>FROM: <a href="mailto:tierone@foobar.com">tierone@foobar.com</a><br>SUBJECT: FooBar Helpdesk Call - 1234567 - Escalation<br>
<br><br>Condition: On Create<br>Action: User Defined<br>Template: Global template: Blank<br>Stage: TransactionCreate<br><br>---------------------------------------------------------------------<br>CUSTOM CONDITION<br>---------------------------------------------------------------------<br>
--left blank--<br><br>---------------------------------------------------------------------<br>CUSTOM ACTION PREPARATION CODE<br>---------------------------------------------------------------------<br># Setup the check for the email address<br>
my $from_address = '<a href="mailto:tierone@foobar.com">tierone@foobar.com</a>';<br><br># Get who created this ticket and exit if it doesn't<br># match the system address from above<br>my $requestor_address = lc($self->TicketObj->RequestorAddresses);<br>
if ($requestor_address ne $from_address) {<br> ## Not from my company, so don't want to parse the subject line <br> return 0;<br>} else { <br> return 1;<br>}<br><br><br>---------------------------------------------------------------------<br>
CUSTOM ACTION CLEANUP CODE<br>---------------------------------------------------------------------<br>### Extract fields from e-mail<br>## my $MyName = "Scrip DNS:35:Commit (New Ticket)";<br>my $Transaction = $self->TransactionObj;<br>
my $CurrentUser = $Transaction->CurrentUser;<br>my $Ticket = $self->TicketObj;<br>my $qNagme = 2;<br>my $NewPri = 90;<br>my $Content = $Ticket->Subject;<br># The seperator is<br>my $sep = " - ";<br>chomp $sep;<br>
$Content =~ s/\A$sep\n//s;<br>chomp $Content;<br>my ($issueCO, $issueID, $issueType) = split($sep, $Content);<br>set_custom('Escalation_ID',$issueID, 0);<br># set_custom('Escalation_Type', $issueType, 0);<br>
# set_custom('Incoming_Co', $userCO, 0);<br><br>### Leave this until last, it triggers the ack e-mail to requestor<br>$Ticket->SetPriority($NewPri);<br><br>### Sets custom field value<br>### Usage: set_custom($field_name, $field_value, $record_transaction)<br>
sub set_custom {<br> my ($CFName, $CFValue, $record) = @_;<br> my $cf = RT::CustomField->new($RT::SystemUser);<br> my ($id,$msg) = $cf->LoadByName(Name=>$CFName,);<br> if (!$id) {<br> $RT::Logger->debug("$MyName: Couldn't load CF ($CFName)");<br>
return undef;<br> }<br> ($id, $msg) = $Ticket->AddCustomFieldValue<br> (Field=>$cf, Value=>$CFValue, RecordTransaction=>$record ? $record : 0);<br>}<br><br><br><br><br><br clear="all"><br>-- <br><a href="http://gentgeen.homelinux.org">http://gentgeen.homelinux.org</a><br>
<br>#############################################################<br> Associate yourself with men of good quality if you esteem <br> your own reputation; for 'tis better to be alone then in bad <br> company. - George Washington, Rules of Civility<br>