[rt-users] Scrip for adding to the custom field based on another CF

Alex Peters alex at peters.net
Wed Jan 21 16:35:47 EST 2015


You should move your scrip code from the Prepare box to the Commit box.
Making changes to tickets in the Prepare stage of a transaction can cause
unintended side effects and is not recommended.

On Thu, 22 Jan 2015 2: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 ;
>
>
>
>
>
> *Custom action preparation code:*
>
> # Define the Custom Field to Act on
> my $CFName = "RMA Num";
>
> #Get the RT Ticket Number
> my $Num = $self->TicketObj->id();
>
> # Define the desired value for the CF
> my $Value = "RMA-" . $Num ;
>
> $self->TicketObj->AddCustomFieldValue( Field => $CFName, Value => $Value );
>
> return 1;
>
>
>
>
> --
> http://www.wikiak.org
>
> #############################################################
>  Associate yourself with men of good quality if you esteem
>  your own reputation; for 'tis better to be alone then in bad
>  company.        - George Washington, Rules of Civility
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20150121/9831fb93/attachment.html>


More information about the rt-users mailing list