[rt-users] Add condition in template

samir marhoum samir.marhoum at gmail.com
Fri Dec 18 12:34:05 EST 2009


Thanks Ken,

What I want is to put the condition in the template: here is my scrip:

Condition: On ticket creation

Action: Notify Requestor

Template : in the template I want to add a variable Cc based on a custom
field value:

Cc: {'based on custom field value'}

But I don't know the code to use for templates (which is a bit different
from the one used for conditions and actions)
Here is an example of someting similar that works for me, but I can't figure
out how to do it wi CFs:

- Based on the ticket priority, a text is added to the template :
(ex: Critique if priority = 20)

------------------------------------
Priority: {$crit = 'Informatif' if $Ticket->Priority == '99'}{$crit =
'critique' if $Ticket->Priority == '20'}{$crit = 'Majeur' if
$Ticket->Priority == '40'}{$crit = 'Mineur' if $Ticket->Priority ==
'60'}{$crit = 'Oteo' if $Ticket->Priority == '80'}
-------------------------------------
2009/12/18 Ken Crocker <kfcrocker at lbl.gov>

> Samir,
>
> I do something similar to that. Based on the value of a (ticket) Custom
> Field, I assign a ticket owner. This is the code I use:
>
>
> #----------------------------------------------------------------------------
> # Custom action preparation code:
>
> #----------------------------------------------------------------------------
> #
> # set new values for Due Date from CF Need-by-Date
> #
>
> my $trans = $self->TransactionObj;
> my $ticket = $self->TicketObj;
> my $cf_date = $ticket->FirstCustomFieldValue('Need-By Date');
>
> # split up the date parts into a temporary array
>
> my @parts = split(/[\/-]/, $cf_date);
>
> # put date parts back together
>
> my $new_date = sprintf("%d-%d-%d", $parts[2], $parts[0], $parts[1]);
>
> # format new date based on RT
>
> my $duedate = RT::Date->new($RT::SystemUser);
> $duedate->Set(Format=>'unknown', Value=>$new_date);
>
> #
> # set new ticket owner id value
> #
> #    42 - Chuck
> #   148 - UK
> #  5125 - Aurora
> #  9324 - Steve
> # 73886 - Ron
> #
>
> my %orgs = qw(
>            Budget-Direct   148
>            Budget-Indirect 148
>            Controller-AP   5125
>            Controller-AR   73886
>            Controller-GA   148
>            Controller-PR   42
>            Facilities      42
>            Field OPS       42
>            OCFO-Other      42
>            Procurement     9324
>            Property        9324
>            SPO             73886
>            Travel          5125
>            Other           42
>           );
>
> my $cf = new RT::CustomField($RT::SystemUser);
> $cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "CFO-Org");
> return 0 unless $cf->id;
> my $cfvalue = $ticket->FirstCustomFieldValue('CFO-Org');
> my $ownerid = $orgs{$cfvalue};
>
> # set Ticket Due date & Owner ID
>
> $ticket->SetDue($duedate->ISO);
> $ticket->SetOwner($ownerid);
>
> return 1;
>
> #----------------------------------------------------------------------------
> # Custom action cleanup code:
>
> #----------------------------------------------------------------------------
>
> return 1;
>
> Obviously, you would not need the "due Date" code. Perhaps you can modify
> this to serve your needs.
>
> Kenn
> LBNL
>
>
> On 12/17/2009 11:49 PM, samir marhoum wrote:
>
>   Can any one help please ?
>
> 2009/12/16 samir marhoum <samir.marhoum at gmail.com>
>
>>  Hi,
>>
>> I need to send email notification based on a custum field value, ie if a
>> CF value is X send email to john at mail.com if it's Y send to
>> peter at company.org
>>
>> Can you please help me on this ?
>>
>> Best Regards.
>>
>
> ------------------------------
>
> _______________________________________________http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20091218/dcd8d4d5/attachment.htm>


More information about the rt-users mailing list