[Vtigercrm-developers] Workflow Custom Functions

Prasad prasad at vtiger.com
Tue Aug 24 11:10:18 PDT 2010


Hi Alan,

$newProject = Project::getInstance('Project');
>

This is vtlib API to administer the module fields/blocks etc...will not help
in creating module records.

Easy way to create module records (5.1.0 onwards), is using Server Side
Webservice API

include_once 'include/Webservices/Create.php';
global $current_user;
$parameters = array( 'fieldname1' => 'fieldvalue1', 'fieldname2' =>
'fieldvalue2' );
$parameters['assigned_user_id'] = sprintf( '19x%s', $current_user->id );
// 19 - Webservice entity id for module Users

$resultRecord = vtws_create( 'ModuleName', $parameters, $current_user );

On Tue, Aug 24, 2010 at 11:09 PM, Alan Lord (News) <alanslists at gmail.com>wrote:

> 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
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20100824/5569fe51/attachment-0002.html 


More information about the vtigercrm-developers mailing list