It will be done by simple steps. Let’s see how
Add below code as per your requirements in any file
If we need to create record in any module, you can achieve using below code,
<?php
$object= new <desired_module>();
$object->name='test';
$object->description='Created for test';
$object->save(true);
$id=$object->id; // so if we need to get the id of this currently created record, you can get it using
To retrieve record using object. you can achieve using below code,
<?php
global $sugar_config,$beanFiles,$beanList;
$bean_name = $beanList['<desired_module>'];
require_once($beanFiles[$bean_name]);
$module_obj= new $bean_name();
$module_obj->retrieve(<id>);
Note :
Here, <desired_module> means the module name you see in the URL, for example, Contacts, Leads, etc.
<id> means id of record
Hope you find this blog post helpful.
Feel free to add comments and queries, that helps us to improve the quality of posts.
You can contact us at [email protected]
Thank you.