<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 14, 2013 at 11:58 PM, Landon Stewart <span dir="ltr"><<a href="mailto:lstewart@iweb.com" target="_blank">lstewart@iweb.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="im">On 14 September 2013 00:19, Ruslan Zakirov <span dir="ltr"><<a href="mailto:ruz@bestpractical.com" target="_blank">ruz@bestpractical.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">


<div>You should go other way around. After calling $template->Parse you call $template->MIMEObj and get MIME::Entity representing result of the template. You then can update this entity with attachments, more headers and so on.</div>


</div></div></div></blockquote><div><br></div></div><div>Hi Ruslan,</div><div><br></div><div>Thanks for your reply.  I've just tried this but now I'm wondering where I get the TicketObj and TransactionObj arguments for $template->Parse.  If I use the Incident's TicketObj and TransactionObj it actually modifies the Incident's subject.</div>


<div><br></div><div>I cannot put the $new_ticket->Create(…) before the $template->Parse because RT::Ticket->Create requires a MIMEObj produced by $template->Parse in $template->MIMEObj.  It's a chicken vs. egg issue here I think.  I must be missing something but I don't know what.  I also tried putting the "my $new_ticket = RT::Ticket->new($RT::SystemUser)" above the template but leave the Create below but I'm still left with no TransactionObj to use because it's generated by RT::Ticket->Create(…).</div>
</div></div></div></blockquote><div><br></div><div><br></div><div>I don't understand your problem here. You have an incident and want to create an investigation with a scrip using a template. Templates are used here so you don't have to change code every time you to change a word or add a new particular text for such investigations.</div>
<div><br></div><div>Here what you do:</div><div><br></div><div>1) scrip is executed when something happens with an Incident, so $self->TicketObj is an Incident</div><div>2) You take Incident's props and use them to generate template name</div>
<div>3) You load template and Parse it, providing as much context as possible to the template</div><div><br></div><div>Here is fun part - RT doesn't care what you pass into template. You can probably even skip all arguments and if your template is capable to work without arguments then it will work.</div>
<div><br></div><div>4) Template can have code embedded, so it can use provided context (in your case Incident) to fill in dynamic details.</div><div>5) Template should not change anything, but format some result</div><div>
6) After parsing you get MIMEObj based on existing Incident, IRs, watchers of these tickets, CFs, transactions...</div><div>7) You complete this MIMEObj with additional data and these actions can be controlled from templates, for example whether IRs's replies should be attached to the Investigation or not can be controlled by 'RTIR-Attach-IRs: yes' header (this is exactly what RT does in notification scrips)</div>
<div>8) Once MIMEObj is complete you create your investigation ticket</div><div><br></div><div>I don't see any chicken&egg problem here. Do you? </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I've pasted a new version of my code at <a href="http://pastebin.com/UvnUC221" target="_blank">http://pastebin.com/UvnUC221</a>.  This version modifies the subject of the Incident ($self).</div>
<span class="HOEnZb"><font color="#888888"><div>

<br></div><div>-- <br></div></font></span></div><div class="im"><div dir="ltr"><div><span style="font-family:arial;font-size:small">Landon Stewart :: </span><a href="mailto:lstewart@iweb.com" style="font-family:arial;font-size:small" target="_blank">lstewart@iweb.com</a><br>


</div><span style="font-family:arial;font-size:small">Lead Specialist, Abuse and Security Management</span><br style="font-family:arial;font-size:small"><span style="font-family:arial;font-size:small">Spécialiste principal, gestion des abus et sécurité</span><br style="font-family:arial;font-size:small">


<span style="font-family:arial;font-size:small"><a href="http://iweb.com" target="_blank">http://iweb.com</a> :: +1 (888) 909-4932</span><br><div><span style="font-family:arial;font-size:small"><br></span></div><div><span style="font-family:arial;font-size:small"><br>


</span></div></div>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards, Ruslan.
</div></div>