Question

I have installed sugar CRM for my personal learning purpose, I want to create a module and simple CRUD operation with smarty, I went through documentation but I didn't get proper idea. I have tried to create a module with Hello World and it worked but I didn't get the proper MVC flow. Can we only create a module through module builder? If someone know about this than please help me out.

Thanks

Was it helpful?

Solution

You can add,update and delete in SugarCRM using following actions.

CRUD Handling:

Save Action:

$bean = BeanFactory::newBean($module);   //Create bean
$bean->name = 'Example Record';   //Populate bean fields
$bean->save();   //Save
$record_id = $bean->id;  //Retrieve the bean id

Update Action:

$bean = BeanFactory::getBean($module, $id);      //Retrieve bean
$bean->update_date_modified = false;      //Set modified flag
$bean->name = 'Updated Name';  //Fields to update
$bean->save();   //Save

Delete Action:

$bean = BeanFactory::getBean($module, $id);     //Retrieve bean
$bean->deleted = 1;    //Set deleted to true
$bean->save(); //Save
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top