onBeforeSaveEntry listener to add/modify data of some fields
See Brandon's post on this here:
What is getContent() / the ContentModel, and how do I use it to get and set custom field values?

Basically when you're setting new custom field values, you should use setContentFromPost

$entry-&gt;setContentFromPost(array(
    'latitude' =&gt; $json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat,
);