[Vtigercrm-developers] Create Sales Order from Potential?

Adam Heinz amh at metricwise.net
Tue Apr 5 08:03:32 PDT 2011


On Tue, Apr 5, 2011 at 10:35 AM, Alan Lord (News) <alanslists at gmail.com> wrote:
> One of our customers wants to add an action button to the Potential
> Detail View that will create a Sales Order, and copy across pertinent
> information.
>
> I'm wondering if anyone has done something similar before so I don't
> have to start from scratch?

Hack alert!  ;)

$potential_focus = new Potentials();
$potential_focus->retrieve_entity_info($record, 'Potentials');
$_REQUEST = $potential_focus->column_fields;
$salesorder_focus = new SalesOrder();
setObjectValuesFromRequest($salesorder_focus);
$salesorder_focus->save();

So basically, we're loading the potential from the db, hacking its
fields into the request, then calling the standard "save from request"
logic.  The setObjectValuesFromRequest() call does a nice job of only
copying over the fields that SalesOrder can use, ASSUMING the field
names line up.  I have been burned at least once by contactid not
matching contact_id.  Poke around in vtiger_field to see what I mean.
I'm still stuck with vtiger 5.0.4 right now, so maybe someone else
knows a better way for a more recent version.



More information about the vtigercrm-developers mailing list