Login or Register

RSS IconRecent posts in this topic

avatar
nickw on Jul 16. 2008. 5:45 pm
Hello,

We just started using ac, and would like to make a change to work for us.
I would like to automatically add a docket id to the name field upon project/ticket creation. The idea behind adding it to the name field, is it works with the system and from that point on it's just treated as a title (thus searchable and easily editable, and doesn't effect anything else down the chain).

I was thinking of grabbing the name field and amending it before AC inserts it to the database. After looking into this and searching I am bumping into some difficulty. In an effort to keep this post as clear & concise as possible, I would rather not clutter it with possibly irrelevant info. So could someone please help/point me in the right direction in order to do this and best integrate it with ac.

Many Thanks,
Nick

The other option would be a feature request for ac to have a docket id which displays under projects & tickets and is searchable. However not everyone would necessarily use this, thus why I thought of just adding it myself.
avatar Staff
Ilija Studen on Jul 17. 2008. 6:23 am
You can do this by handling on_before_object_insert event.

To see how handler looks like open activecollab/application/modules/system/handlers and find on_before_object_insert.php file. Note that handlers need to be registered in handlers.php of every module to be executed.

If you want to change ticket or project information before save you'll need to check if $object is ticket or project:

if(instance_of($object, 'Project')) {
  // ...
} elseif(instance_of($object, 'Ticket')) {
  // ...
}


This can be done as a hack, but it would be best to create a new module with just this handler so you don't need to hack files every time you upgrade. Read more about modules in this article.

Regarding feature request - I honestly don't know what docket ID is and what's it for :)
activeCollab team member | LinkedIn
avatar
nickw on Jul 17. 2008. 3:40 pm
Thanks Ilija

I'll give that a try.

As for docket id, its just a unique number that associates with each project/ticket/workorder etc....

Handy for referencing things in the future, both for duplication, or billing purposes.
IE: When 6 months or 2 years later a client comes back and says they need another ad like they ran in a magazine/paper last year, (and we think there are 100+ ads we have run), its helps be more specific. Or when a client asks why x overran it's budget, we can reference it accurately recall timecard info and remind them of their 100 revisions. You get the idea...

Many agencies/shops use a system like this (or they should).

Thanks again,
N.
avatar Staff
Ilija Studen on Jul 17. 2008. 4:52 pm
Every project and project object (ticket, discussion etc) have unique ID-s, but they are simply numbers that are incremented as objects are added. You can access it with $object->getId() method. Only exceptions are tickets - use $ticket->getTicketId() in that case.
activeCollab team member | LinkedIn
avatar
nickw on Jul 17. 2008. 4:57 pm
I thought of that, only problem is they are each unique, and could/would overlap.
I was just going to have another table that auto inc and pull from there.

Thanks again for your help.
N.
avatar Staff
Ilija Studen on Jul 17. 2008. 4:59 pm
Only overlapping is between project ID-s and project object ID-s because they are two separate tables. Still, you can use prefix P for project and PO for project object. This way you don't need an additional table.

PS: Ticket is also project object so it has unique project object ID. Ticket ID is additional field and is ticket number in a specific project.
activeCollab team member | LinkedIn
avatar
nickw on Jul 23. 2008. 5:35 pm
double post. please delete. thx.
avatar
nickw on Jul 23. 2008. 5:37 pm
Hello Again Ilija

Tried to put in the code today.
Ran into an issue.

if(instance_of($object, 'Project')) {  
	$docket_id = '12345';
	$name .= " - [" . $docket_id . "]";

  } elseif(instance_of($object, 'Ticket')) {  
  // ...  
} 



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.

Thanks,
Nick
avatar Staff
Ilija Studen on Jul 23. 2008. 5:43 pm
Try this:

if(instance_of($object, 'Project')) {  
  $docket_id = '12345';
  $object->setName($object->getName() . " - [" . $docket_id . "]");
  $object->save();
} elseif(instance_of($object, 'Ticket')) {  
  // ...  
}
activeCollab team member | LinkedIn
avatar
nickw on Jul 23. 2008. 5:53 pm
Thanks for the code, but still no luck.
I am putting it in the file activecollab/application/modules/system/handlers/on_before_object_insert.php
I tried at the beginning & end of file.

Right now the name is just inserted as entered and not amended.

RSS IconRecent posts in this topic