I create the guid beforehand and save it with the record so I know it.
Here's a function to create a guid
PHP Code:
function guid(){
if (function_exists('com_create_guid')){
return com_create_guid();
}else{
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtolower(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
}
}
Then you just add a line between your lines like:
PHP Code:
$contact = new Contact();
$contact->id = guid();
$contact->first_name = $bean->fdc_first_name;
Then you can reference $contact->id or save it to another temporary variable to use later.
Phil
[Edit - looks like SugarDev snuck in before me with a similar answer and better data regarding using the bean with hooks]
Bookmarks