Scheduler failed for a problem in retrieve Bean

HI all I recently migrated to SugarEnt 12 and some schedulers I previosly used now fail due to the following error

Job d7de6128-06b1-11ed-9a24-42010ac60064 (name of the scheduler) failed in CRON run, Argument 2 passed to Sugarcrm\Sugarcrm\AccessControl\AccessControlManager::allowRecordAccess() must be of the type string or null, object given, called in /var/www/html/crm/data/BeanFactory.php on line 58

Now I look at row 58 of BeanFactory and it is related to the getBean function and in particular

if (!AccessControlManager::instance()->allowRecordAccess($module, $id)) {
throw new SugarApiExceptionNotFound('This record is not found for your license type.');

In my code, i retrieve a Bean based on the relationship id like this

$mybean = BeanFactory::retrieveBean('custom_module', $othemoduleBean->subscriptions_ptf_ptf_ida);

$othemoduleBean->subscriptions_ptf_ptf_ida exists and I can print on sugarcrm.log. 

I don't know why this happen because the scheduler is executed with admininstrator

Thank you in advance for any help