The advice contained in this post is out of date.
One problem developers that are just getting started with SugarCRM seem to run into in the use of logic hooks. Logic hooks are a powerful mechanism to interject business logic in the places in the application where in is most often needed, such as when you retrieve and save record, login or logout of the application, or set or delete a relationship between records.
A common question that pops up on the forums revolves around record detection. Let’s say you have a logic hook where you only want the logic execute if the field has changed value. In this case, you’ll want to enclose your logic in an if block such as this ( thanks to davidboris on the forums for this tip ):
Another question is how do you specify logic that should only be executed on the initial record creation, but not on subsequent saves. You can use a similar technique to what is above, instead simplying checking if the fetched_row array has the id element set.