AnsweredAssumed Answered

retrieve_by_string_fields works, retrieveBean doesn't

Question asked by toddkaufmann toddkaufmann on Aug 27, 2014
Latest reply on Aug 28, 2014 by Jason Eggers
SugarPro 7.2, 
I've read lots of posts, code, and documentation,
but some things aren't working...
function ex_1140() {
  $t_id = '6145092d-43a0-b3ea-a2f1-53f668c90d17';
  $module = 'Accounts';
  $tb = BeanFactory::newBean( $module );
  $tb->retrieve_by_string_fields( array( 'id' => $t_id ) );  // works
  echo "Loaded account:  $tb->name\n";
  // try other way
  echo "Now trying: BeanFactory::retrieveBean( $tb->module_name, $tb->id );\n";
  $tb2 = BeanFactory::retrieveBean( $tb->module_name, $tb->id );
  if ( $tb2 === NULL ) {  echo "SORRY, doens't work.\n"; }

php > ex_1140();
Loaded account:  test3 co
Now trying: BeanFactory::retrieveBean( Accounts, 6145092d-43a0-b3ea-a2f1-53f668c90d17 );
SORRY, doens't work.
The first bean ($tb) is loaded via retrieve_by_string_fields just fine ("test3 co"),
but retrieveBean returns NULL, using obviously the same module and object uuid.  
Did I miss something somewhere ?

Note:  I am running this interactively at the command line ("php -a"), from the root of my Sugar install, using this initialization:
    define('sugarEntry', true);
    $GLOBALS['sugar_config'] = $sugar_config;

which has alway worked for me before (since 6.x).  
Trying things out on the command line is just so much faster.
(Is there another fast easy way to test Sugar code?)