SetCustomFieldViaMail: Difference between revisions
Jump to navigation
Jump to search
m (→EXAMPLE 1: CF Value based on destination email address: formatting) |
m (moar formatting) |
||
Line 7: | Line 7: | ||
== EXAMPLE 1: CF Value based on destination email address == | == EXAMPLE 1: CF Value based on destination email address == | ||
Condition: OnCreate | |||
Action: User Defined | |||
Template: Global template: Transaction | |||
Stage: TransactionCreate | |||
CUSTOM CONDITION: | CUSTOM CONDITION: | ||
Line 67: | Line 66: | ||
== EXAMPLE 3: CF & Title change based on requestor's email address (returns $1 @ $2) == | == EXAMPLE 3: CF & Title change based on requestor's email address (returns $1 @ $2) == | ||
Condition: OnCreate | |||
Action: User Defined | |||
Template: Global template: Transaction | |||
Stage: TransactionCreate | |||
Line 77: | Line 76: | ||
PREPARATION CODE: | PREPARATION CODE: | ||
return 1; | |||
CLEANUP CODE: | CLEANUP CODE: | ||
my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); | |||
$ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/; | |||
if ( $2 =~ /^gmail.com$/m ) { | |||
$self->TicketObj->AddCustomFieldValue( Field => 'Some CF', Value => 'SOME VALUE' ); | |||
$self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'ONE' ); | |||
$self->TicketObj->SetSubject ('TAG: '.$self->TicketObj->Subject); | |||
} | |||
Line 98: | Line 96: | ||
Pre-Requirements: | Pre-Requirements: | ||
* You will have to create specific sub-groups and add members to be notified | |||
* You will need "rt-notify-group-admin" to create scrip Actions to notify the above sub-groups | |||
<nowiki></nowiki> | |||
Condition: User Defined | |||
Action: Notify YOURGROUP | |||
Template: Global template: Transaction | |||
Stage: TransactionCreate | |||
CUSTOM CONDITION: | CUSTOM CONDITION: | ||
my $to = $self->TransactionObj->Attachments->First->GetHeader('To'); | |||
my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); | |||
$ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/; | |||
if ($to =~/^nms\@.*\.?yourdomain\.net/) { | |||
$self->TicketObj->AddCustomFieldValue( Field => 'Type', Value => 'NAGIOS' ); | |||
return 1; | |||
} else { | |||
return 0; | |||
} | |||
if ( $1 =~ /^nagios$/m ) { | |||
$self->TicketObj->AddCustomFieldValue( Field => 'Type', Value => 'NAGIOS' ); | |||
return 1; | |||
} else { | |||
return 0; | |||
} | |||
PREPARATION CODE: | PREPARATION CODE: | ||
return 1; | |||
CLEANUP CODE: | CLEANUP CODE: | ||
return 1; | |||
Latest revision as of 22:41, 20 February 2019
RT 3.8
The following example Scrips will help set ticket's CF values, change title or parameters, and notify specific groups based on email properties as detected by RT; Examples partially based on older WiKi entries and adapted where needed. CF names and values are purely fictional examples, please don't copy and paste without proper understanding of setup and requirements. Requestors will need appropriate permissions to create/modify CF values for this to work.
Posted & Tested on 3.8.7 by webdelic@gmail.com
EXAMPLE 1: CF Value based on destination email address
Condition: OnCreate Action: User Defined Template: Global template: Transaction Stage: TransactionCreate
CUSTOM CONDITION:
PREPARATION CODE:
return 1;
CLEANUP CODE:
my $to = $self->TransactionObj->Attachments->First->GetHeader('To'); if ($to =~/^partial\@.*\.?yourdomain\.net/) { $self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'ONE' ); } if ($to =~/fixed\@.*\.?yourdomain\.net/) { $self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'TWO' ); } $self->TicketObj->SetPriority( 1 ); return 1;
EXAMPLE 2: CF Value based on requestor's email address (returns $1 @ $2)
Condition: OnCreate Action: User Defined Template: Global template: Transaction Stage: TransactionCreate
CUSTOM CONDITION:
PREPARATION CODE:
return 1;
CLEANUP CODE:
my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); $ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/; if ( $1 =~ /^username$/m ) { $self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'ONE' ); } if ( $2 =~ /^yourdomain.net$/m ) { $self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'TWO' ); } $self->TicketObj->SetPriority( 1 ); return 1;
EXAMPLE 3: CF & Title change based on requestor's email address (returns $1 @ $2)
Condition: OnCreate Action: User Defined Template: Global template: Transaction Stage: TransactionCreate
CUSTOM CONDITION:
PREPARATION CODE:
return 1;
CLEANUP CODE:
my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); $ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/; if ( $2 =~ /^gmail.com$/m ) { $self->TicketObj->AddCustomFieldValue( Field => 'Some CF', Value => 'SOME VALUE' ); $self->TicketObj->AddCustomFieldValue( Field => 'Region', Value => 'ONE' ); $self->TicketObj->SetSubject ('TAG: '.$self->TicketObj->Subject); }
EXAMPLE 4: Notify Groups based on req/destination email or CF Values
Pre-Requirements:
- You will have to create specific sub-groups and add members to be notified
- You will need "rt-notify-group-admin" to create scrip Actions to notify the above sub-groups
Condition: User Defined Action: Notify YOURGROUP Template: Global template: Transaction Stage: TransactionCreate
CUSTOM CONDITION:
my $to = $self->TransactionObj->Attachments->First->GetHeader('To'); my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); $ticketRequestor =~ /(^.+)@([^\.].*\.[a-z]{2,}$)/; if ($to =~/^nms\@.*\.?yourdomain\.net/) { $self->TicketObj->AddCustomFieldValue( Field => 'Type', Value => 'NAGIOS' ); return 1; } else { return 0; } if ( $1 =~ /^nagios$/m ) { $self->TicketObj->AddCustomFieldValue( Field => 'Type', Value => 'NAGIOS' ); return 1; } else { return 0; }
PREPARATION CODE:
return 1;
CLEANUP CODE:
return 1;