[Vtigercrm-developers] Workflow Custom Functions
Alan Lord (News)
alanslists at gmail.com
Tue Aug 24 13:38:45 PDT 2010
On 24/08/10 20:05, Prasad wrote:
> Hi Alan,
>
> "Warning: require(user_privileges/user_privileges_.php): failed to
> open stream: No such file or directory in
>
>
> You need to pass the user instance to vtws_create API.Make sure
> $current_user is declared as global and is intitlazied.
It was, but outside the function :-D
Anyway, it now seems to work quite well! Thanks for your help Prasad.
Below is the function as a whole so far. As you can see there are quite
a few fields being passed that are hard-coded and would be problematic
to pass any-other way.
It would be useful to know the right thing to do should an error occur
though - I just made something up for now and I'm not even sure that it
would work anyway.
One other idea I had, was that it would be good if we were able to
install these custom functions through something like the module manager
function. I wondered if I packaged it as as an "extension module"
whether it would actually get installed. I might give that a go later.
CustomWorkflowHandler Function
function Project_WorkflowTask_AutoCreateFn($entity) {
global $current_user;
// 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');
include_once 'include/Webservices/Create.php';
$date = date("Y/m/d");
// Assemble the necessary Project fields
$parameters = array(
'projectname' => $name,
'startdate' => $date,
'targetenddate' => $date,
'actualenddate' => $date,
'description' => $description,
'projectstatus' => '--none--',
'projecttype' => '--none--',
'progress' => '--none--',
'assigned_user_id' => $assigned_to,
'targetbudget' => $budget,
'linktoaccountscontacts' => $related_to
);
if ($resultRecord = vtws_create('Project', $parameters, $current_user)) {
echo "Sorry there was an error:\n";
echo "<pre>"; print_r($resultRecord); echo "</pre>\n";
}
}
Cheers
Al
--
The Open Learning Centre
http://www.theopenlearningcentre.com
More information about the vtigercrm-developers
mailing list