PHP, SugarCRM, Javascript, Cool Web Apps Developer

Blog

Create Object and Retrieve record by creating Object.

Posted by swapnil shinde on March 26, 2012 at 4:05 AM

Hi,

So many times we need to create records into related modules so instead of inserting records into their tables and its custom table we can create the object of that module and call its function save().

So once u call that function it will also execute its logic hooks as well.

so we just need to include the file of that module.


eg.


require_once('modules/module/module.php');

$object= new module();

$object->name='test';

$object->description='Created for test';

$object->save(true);

so if we need to get the id of this currently created record, u can get it using

$id=$object->id;



To retrive record using object.

declare

global $sugar_config,$beanFiles,$beanList; in your file

$bean_name = $beanList['Module_Name'];

require_once($beanFiles[$bean_name]);

$module_obj= new $bean_name();

$module_obj->retrieve(id of record);

now suppose if u want to find name of record.

use $module_obj->name;

you can even get custom field in same way.

Categories: Mar2012-SugarCRM Help

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments