<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>aC forum: Help adding a docket id to the name field for projects/tickets</title>
  <link>http://www.activecollab.com/forums/topic/2981/</link>
  <description>Recent posts on topic: Help adding a docket id to the name field for projects/tickets</description>
  <dc:language>en-us</dc:language>
  <pubDate>Wed, 03 Dec 2008 01:08:31 UTC</pubDate>
  
  <item>
    <link>http://www.activecollab.com/forums/post/14044/#post14044</link>
    <guid>http://www.activecollab.com/forums/post/14044/#post14044</guid>
    <title>Post #16 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>Okay its workin' now! Thanks. <br />
I see what the problem was now.<br />
I was instering the code at the end of the file (also tried begining), and I needed to insert it in after:<br />
<br />
<pre name="code" class="php">function system_handle_on_before_object_insert($object) { </pre><br />
<br />
Thanks again.<br />
Nick.</p>]]></description>
    <pubDate>Thu, 24 Jul 2008 19:36:44 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14029/#post14029</link>
    <guid>http://www.activecollab.com/forums/post/14029/#post14029</guid>
    <title>Post #15 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Just tested - code is working. Here is how entire handler looks like:<br />
<br />
<pre name="code" class="php">function system_handle_on_before_object_insert($object) {
  if(instance_of($object, 'Project')) {
    $object-&gt;setName($object-&gt;getName() . ' [#123]');
  }
  
  if($object-&gt;fieldExists('created_on')) {
    if(!isset($object-&gt;values['created_on'])) {
      $object-&gt;setCreatedOn(new DateTimeValue());
    } // if
  } // if
  
  $user =&amp; get_logged_user();
  if(!instance_of($user, 'User')) {
    return;
  } // if
  
  if($object-&gt;fieldExists('created_by_id') &amp;&amp; !isset($object-&gt;values['created_by_id'])) {
    $object-&gt;setCreatedById($user-&gt;getId());
  } // if
  
  if($object-&gt;fieldExists('created_by_name') &amp;&amp; !isset($object-&gt;values['created_by_name'])) {
    $object-&gt;setCreatedByName($user-&gt;getDisplayName());
  } // if
  
  if($object-&gt;fieldExists('created_by_email') &amp;&amp; !isset($object-&gt;values['created_by_email'])) {
    $object-&gt;setCreatedByEmail($user-&gt;getEmail());
  } // if
} // system_handle_on_before_object_insert</pre><br />
<br />
I've attached a screenshot with a project overview page. You can see that project name is properly altered before save.</p>]]></description>
    <pubDate>Thu, 24 Jul 2008 15:27:49 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14028/#post14028</link>
    <guid>http://www.activecollab.com/forums/post/14028/#post14028</guid>
    <title>Post #14 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>Existing. I elected to add my code to yours, and document my changes.<br />
It's in on_before_object_insert.php<br />
Sorry this is turning into a pain...</p>]]></description>
    <pubDate>Thu, 24 Jul 2008 15:12:31 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14015/#post14015</link>
    <guid>http://www.activecollab.com/forums/post/14015/#post14015</guid>
    <title>Post #13 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>It this the new or existing handler file? Do you have it registered in handlers.php of that specific module?</p>]]></description>
    <pubDate>Thu, 24 Jul 2008 04:46:04 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14014/#post14014</link>
    <guid>http://www.activecollab.com/forums/post/14014/#post14014</guid>
    <title>Post #12 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>Still no go.<br />
Doesn't give any errors, it just creates the project with the original name.<br />
<br />
</p>]]></description>
    <pubDate>Wed, 23 Jul 2008 22:27:40 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14007/#post14007</link>
    <guid>http://www.activecollab.com/forums/post/14007/#post14007</guid>
    <title>Post #11 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Oh, in that case try this:<br />
<br />
<pre name="code" class="php">if(instance_of($object, 'Project')) {  
  $docket_id = '12345';
  $object-&gt;setName($object-&gt;getName() . &quot; - [&quot; . $docket_id . &quot;]&quot;);
} elseif(instance_of($object, 'Ticket')) {  
  // ...  
}</pre></p>]]></description>
    <pubDate>Wed, 23 Jul 2008 18:09:49 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14006/#post14006</link>
    <guid>http://www.activecollab.com/forums/post/14006/#post14006</guid>
    <title>Post #10 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>Thanks for the code, but still no luck.<br />
I am putting it in the file activecollab/application/modules/system/handlers/on_before_object_insert.php <br />
I tried at the beginning &amp; end of file.<br />
<br />
Right now the name is just inserted as entered and not amended.</p>]]></description>
    <pubDate>Wed, 23 Jul 2008 17:53:02 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14005/#post14005</link>
    <guid>http://www.activecollab.com/forums/post/14005/#post14005</guid>
    <title>Post #9 by Ilija Studen</title>
    <dc:creator>Ilija Studen</dc:creator>
    <description><![CDATA[<p>Try this:<br />
<br />
<pre name="code" class="php">if(instance_of($object, 'Project')) {  
  $docket_id = '12345';
  $object-&gt;setName($object-&gt;getName() . &quot; - [&quot; . $docket_id . &quot;]&quot;);
  $object-&gt;save();
} elseif(instance_of($object, 'Ticket')) {  
  // ...  
}</pre></p>]]></description>
    <pubDate>Wed, 23 Jul 2008 17:43:44 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14004/#post14004</link>
    <guid>http://www.activecollab.com/forums/post/14004/#post14004</guid>
    <title>Post #8 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>Hello Again Ilija<br />
<br />
Tried to put in the code today.<br />
Ran into an issue.<br />
<br />
<pre name="code" class="php">
if(instance_of($object, 'Project')) {  
	$docket_id = '12345';
	$name .= &quot; - [&quot; . $docket_id . &quot;]&quot;;

  } elseif(instance_of($object, 'Ticket')) {  
  // ...  
} </pre><br />
<br />
<br />
Docket id will get set later, I just wanted to run a test. However I can't seem to amend the name. I tried a few variations, however none seemed to work. Once again I will try and avoid clutter with everything I tried. Above is just a sample of a variation. Any help would be appreciated.<br />
<br />
Thanks,<br />
Nick</p>]]></description>
    <pubDate>Wed, 23 Jul 2008 17:37:25 UTC</pubDate>
  </item>
  <item>
    <link>http://www.activecollab.com/forums/post/14003/#post14003</link>
    <guid>http://www.activecollab.com/forums/post/14003/#post14003</guid>
    <title>Post #7 by nickw</title>
    <dc:creator>nickw</dc:creator>
    <description><![CDATA[<p>double post. please delete. thx.</p>]]></description>
    <pubDate>Wed, 23 Jul 2008 17:35:18 UTC</pubDate>
  </item>
</channel>
</rss>