[Vtigercrm-developers] Workflow Custom Functions

Alan Lord (News) alanslists at gmail.com
Tue Aug 24 10:39:32 PDT 2010


On 21/08/10 11:27, Prasad wrote:
<snip />
> Keep us posted with your experiments.

Hey, I bet you wish you never asked!

I'm struggling at the stage of creating and saving a new Project 
object... I was thinking I should try and do this "The Right Way", 
rather than just writing to the db directly in my function:

So, my CustomWorkflowHandler Function looks like this:

require_once("modules/Project/Project.php");

function Project_WorkflowTask_AutoCreateFn($entity) {
	
   // Get the information for the New Project
   $name = $entity->get('potentialname');
   $description = $entity->get('description');
   $budget = $entity->get('amount');
   $related_to = $entity->get('related_to');
   $assigned_to = $entity->get('assigned_user_id');

   // Get a new Project Object
   $newProject = Project::getInstance('Project');

   // Override the Project Module parameters with the data from the 
Potential
   $newProject->projectname = $name;
   $newProject->description = $description;
   $newProject->related_to = $related_to;
   $newProject->assigned_user_id = $assigned_to;

   $newProject->save('Project');
	
?>

I've been examining the Objects I have instantiated and I know the above 
is *wrong*.

But there doesn't seem to be a built-in method for overriding the 
module's properties, nor indeed, setting up some defaults like the 
'Module No' field (I thought initRequiredFields() in the CRMEntity class 
might do the trick, but it doesn't appear to make any difference).

Sorry I'm being so thick.

Al


-- 
The Open Learning Centre
http://www.theopenlearningcentre.com




More information about the vtigercrm-developers mailing list