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.

  • Hi hat,

    My file was was in sugar_directory/process/testBean.php.

    I could not get it to work there every time a call was made it was redirecting me to the file install.php, so i just moved teastBean.php inside Sugar's root directory and it works now. I will go with this solution for now, but i am still interested why it was not working when it was nested a directory.

    Thanks,

Reply Children
No Data