<div>Hi,</div><div><br></div><div>I've finished the scrip with my initial purpose, which was to set the ticket type (incident, problem or change) along with the priority (1 to 5) and based on those two values set the SLA field (from the SLA plugin/addon).</div>
<div><br></div><div>The result is listed below, this basically does the following:</div><div><ul><li>CF Type && CF Prio = SLA</li><li>System Prio = CF Prio</li></ul><div>The reason why I'm using a CF for the prio is to make it easy for our personell to select a value upon creating a ticket + it forces them to select a fixed vlaue (dropdown) which makes it a little faster as well.</div>
</div><div>In addition I'm also making sure the system prio field is set to the same value as the CF Prio.</div><div><br></div><div>Details for this scrip are below:</div><div><meta charset="utf-8"><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(68, 68, 68); font-family: arial, sans-serif; font-size: 13px; "><ul>
<li style="margin-left: 15px; ">Condition: On Transaction</li><div class="im" style="color: rgb(51, 51, 51); "><li style="margin-left: 15px; ">Action: User Defined</li><li style="margin-left: 15px; ">Template: Global Template: Transaction</li>
</div><li style="margin-left: 15px; ">Stage: TransactionBatch</li><div class="im" style="color: rgb(51, 51, 51); "><li style="margin-left: 15px; ">Custom condition: (empty)</li><li style="margin-left: 15px; ">Custom action preparation code: return 1;</li>
<li style="margin-left: 15px; ">Custom action cleanup code:</li></div></ul></span></div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace"># Set the value of the CF's Type and Prio to a variable</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">my $my_type = $self->TicketObj->FirstCustomFieldValue('Type');</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">my $my_prio = $self->TicketObj->FirstCustomFieldValue('Prio');</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"># Change the system's Prio value to the value inside CF Prio</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">$self->TicketObj->SetPriority ($my_prio);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"># INCIDENT</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Incident' && $my_prio == '1') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Urgent'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Incident' && $my_prio == '2') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Normal'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Incident' && $my_prio == '3') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Low'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"># CHANGE</font></div></div><div>
<div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Change' && $my_prio == '1') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Urgent'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Change' && $my_prio == '2') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Normal'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Change' && $my_prio == '3') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Low'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace"># PROBLEM</font></div></div><div>
<div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Problem' && $my_prio == '1') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Urgent'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Problem' && $my_prio == '2') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Normal'); }</font></div>
</div><div><div><font class="Apple-style-span" face="'courier new', monospace">if ($my_type == 'Problem' && $my_prio == '3') { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Low'); }</font></div>
</div></blockquote><div><br></div><div>Now all that's left for me is to expand the SLA's to contain numbers instead of names ( e.g. SLA 4 would mean 4 hours, could be used for both Incident and Change).</div><div>
But those are filling in the details, the above could be easily changed and perfected to trigger the proper SLA value.</div><div><br></div><div>Thanks again for all the help, sometimes your just banging your head on something simple and this just happend to be one of those things :)</div>
<div><br clear="all">Best regards,<br><br>Bart<br><br>
<br><br><div class="gmail_quote">2011/7/26 Bart <span dir="ltr"><<a href="mailto:bart@pleh.info">bart@pleh.info</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Kevin,<div><br></div><div>Thanks for your reply, that turned out to be toe golden tip :D</div><div><br></div><div>I was getting those messages in the Web UI and after changing the type to transaction batch it worked :D<div>
<br></div><div>So to summarize, here's the end result that worked perfectly for me:</div><div><ul><li>Condition: On Transaction</li><div class="im"><li>Action: User Defined</li><li>Template: Global Template: Transaction</li>
</div><li>Stage: TransactionBatch</li><div class="im">
<li>Custom condition: (empty)</li><li>Custom action preparation code: return 1;</li><li>Custom action cleanup code:</li></div></ul><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">
my $my_type = $self->TicketObj->FirstCustomFieldValue('Type');<div class="im"><br>if ($my_type =~ /^I/) { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Urgent'); }<br>
</div>if ($my_type =~ /^C/) { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Normaal'); }<br>
if ($my_type =~ /^P/) { $self->TicketObj->AddCustomFieldValue(Field => 'SLA', Value => 'Laag'); }</blockquote><div><br></div><div>All I have to do now is expand the scrip to also check another field, but that shouldn't be a problem now that this is working :D</div>
<div><br></div><div>Thanks for the help.</div><div> </div></div></div><div><br clear="all">Best regards,<br><font color="#888888"><br>Bart<br><br>
<br><br></font><div class="gmail_quote"><div><div></div><div class="h5">2011/7/26 Kevin Falcone <span dir="ltr"><<a href="mailto:falcone@bestpractical.com" target="_blank">falcone@bestpractical.com</a>></span><br></div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
<div>On Tue, Jul 26, 2011 at 02:40:21PM +0200, Bart wrote:<br>
> The first problem I have is that the SLA is already set to the value "Normal", I see the scrip<br>
> running but it keeps saying "Set SLA Low to Normal" or similar for Urgent (normal is ignored).<br>
> So I get a feeling it does something, but it doesn't actually change the content of the SLA<br>
> field.<br>
> Maybe it's the type of CF that the SLA field is, it's a dropbox with the three options Urgent,<br>
> Normal and Low. But I thought it shouldn't matter?!<br>
> The second problem is that if the SLA field is set to (no value) then the scrip gives the<br>
> error "Low is no longer a value for custom field SLA", which could be the same issue as the<br>
> first? Not able to fill the actual field?<br>
> Any thoughts on this? (the above code is a little different but I get the same results as the<br>
> first code)<br>
<br>
</div>Where do you see these messages, in the webui? Are you doing this on<br>
create or from the Basics page and setting the SLA to normal or unset<br>
there?<br>
<br>
You may need to switch your scrip type to transactionbatch to it runs<br>
after the web updates finish.<br>
<font color="#888888"><br>
-kevin<br>
</font><br><br></div></div><div class="im">
--------<br>
2011 Training: <a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a><br></div></blockquote></div><br></div></div>
</blockquote></div><br></div>