Alan Storm Alan Storm - 1 year ago 114
PHP Question

SugarCRM: Direct Bean Property Access vs. getFieldValue

In modern versions of SugarCRM, after you load data into a bean object

$account = BeanFactory::getBean('Accounts')
->retrieve_by_string_fields(array('name'=>'Q.R.&E. Corp'));

You can fetch data either by directly accessing the property


or by using


Is there any historical reason that
exists? Is there a canonical way of deciding when to use
vs the direct object property method?

Answer Source

The only difference I'm seeing is that it will not throw PHP errors if the field doesn't exist, and if it's a boolean value it will convert it to an integer. See the function definition...

function getFieldValue($name)
    if (!isset($this->$name)){
        return FALSE;
    if($this->$name === TRUE){
        return 1;
    if($this->$name === FALSE){
        return 0;
    return $this->$name;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download