[rt-users] Scrip for adding to the custom field based on another CF
Landon Stewart
lstewart at iweb.com
Wed Jan 21 13:43:33 EST 2015
On Jan 21, 2015, at 7:07 AM, Kevin Squire <gentgeen at wikiak.org> 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 : lstewart at iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20150121/9e424b2c/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20150121/9e424b2c/attachment.sig>
More information about the rt-users
mailing list