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