Generating an ID with BeanFactory

Hello,

I am having trouble generating a new record with BeanFactory, i receive:

PHP Fatal error:  Uncaught Error: Class 'Sugarcrm\Sugarcrm\Util\Uuid' not found in /home/sugar8/public_html/include/utils.php:1428

my code looks like this

<?php

if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
require_once '/home/sugar8/www/data/BeanFactory.php';
require_once '/home/sugar8/www/include/utils.php';


$testAccountBean = BeanFactory::newBean('Bugs');
$id = create_guid();

?>

Thanks,

Parents
  • Hi Web Team,

    Which location are you writing this file to?

    If you are writing this in sugar root directory or outside of sugar root directory, please include entryPoint.php file.

    require_once('include/entryPoint.php');

    Also, using BeanFactory, you do not need to create/specify ID explicitly until and unless you have any special requirement where you want to generate user defined IDs or wanted to pass ID from some other function. Below code is enough to generate a new Bug record in sugar.

    $bugBean = BeanFactory::newBean("Bugs");
    $bugBean->name = "Test Bug";
    $bugBean->save();

    Let us know if this helps.

    Regards.

  • BeanFactory interface provides a simple, yet flexible configuration mechanism to manage objects of any nature via the Spring IoC container. Let's have a look at some basics before diving deep into this central Spring API.

Reply Children
No Data