SugarCRM: check updating of object’s property

Sometimes it’s needed to know about updating of specified object’s property. SugarCRM keeps previous values for all object’s properties in the array fetched_row. For example, to realise it’s new object or just updated we should compare ID from that array and current value of object’s property:
if($obj->fetched_row['id'] != $obj->id) {
echo "This's a new object!\n";
} else {
echo "This's an existing object\n";
}

That approach might be used in the handler of logic hook, for example, to perform some action when desire property is changed.

Published by

Michael Stepanov

Site owner and admin :)

2 thoughts on “SugarCRM: check updating of object’s property”

  1. That is the sign of just how bad SugarCRM orm still is. In Rails you’d check it with simple “record.new_record?” call, which is much more natural.

  2. It’s easy to create your own wrapper for SugarCRM as well 🙂 I suspect nobody need it. Moreover, Rails is framework but Sugar – software product based on PHP 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *