BeanFactory::getBean not returning existing record in SugarCRM custom code

I have a SugarCRM integration. It has the following line in the code

$beanToSync = BeanFactory::getBean($moduleToCheck, $beanToSync->id);

In $moduleToCheck the module 'Leads' is passed and $beanToSync->id have an ID of an existing Lead in SUgarCRM.

After this line is executed the $beanToSync does not have that existing record fetched and it returns an empty bean.

The code is working fine on my localhost and also on Sugar Cloud Dev environment. Now I installed it on another Sugar Cloud instance and I am getting this issue. I haven't made any changes in the code and I am unable to find any clue to handle this issue. Is there anyone who can help?

The Sugar local instance version is 11.0 and the Cloud instances version is 11.3 and 12.0 (Sugar Sell).

Thanks

  • : Without more details, it is tough to diagnose. Whom is the user running the function BeanFactory::getBean($moduleToCheck, $beanToSync->id)? Does this user have permission to view this record? In other words, are they on a team or a member of a role that prevents access? Is the record marked for deletion? delete = 1?

  • Try this approach:

    $beanToSync = BeanFactory::getBean($moduleToCheck, $beanToSync->id, ['disable_row_level_security' => true]);

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Yes, the user have permission to view that record and the record is not marked for deletion