On Jan 21, 2015, at 7:07 AM, Kevin Squire <[email protected]> wrote:
> 
> 
> I have a scrip currently that checks for status change from X--> Y and if 
> true, adds an entry to the Custom Field "RMA Num".  It adds our RMA number, 
> which is really just "RMA-$RT_Ticket_Number"
> 
> They have asked me to change the number based on another CF "RMA TYPE".  If 
> the RMA type = "Student Withdrawl" they want the RMA number to be appended 
> with "WD"
> 
> 
> My perl skills are limited to copy/paste and tweaking existing.... so I would 
> like a little bit of help with my If/Then statement.  The idea being:
> 
> IF CustomField{RMA Type} = Student Withdrawl
> THEN $Append = "-WD"
> ELSE $Append = ""
> 
> Then in the current line (below)
>              my $Value = "RMA-" . $Num ;
> 
> would be changed to
>       my $Value = "RMA-" . $Num . $Append ;

This can be done with one ternary operator:
my $value = $self->TicketObj->FirstCustomFieldValue('RMA Type') eq 'Student 
Withdrawl' ? "RMA-" . $Num : "RMA-" . $Num . $Append;

Some notes:
- The condition here is:  $self->TicketObj->FirstCustomFieldValue('RMA Type') 
eq 'Student Withdrawl'
- If the condition is true then $value will equal what's between the ? and the 
: (colon)
- If the condition is false then $value will equal what's between the : and the 
; (semi-colon)

Landon Stewart : [email protected]
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to