Hi all
I have succesfully make a workflow that converts won opportunities to new projects. Iāve managed to carry forward all the fields except for ācontactā explained further below.
There is no option to map the contact field in the workflow, has any one any ideas?
Thanks
Dan
The contact or contact(s) related to the Opportunity is not a field, its a relationship. If you want to carry the contacts related to the opportunity over to project you have to map the relationship. I donāt think you can do this through workflow. Iāve always written a before save hook to map the contacts over. If you had a field in Opps like āmain contactā and wanted to carry that over to Projects you could. Really what you want to do is write a hook that loops through the relationships of the Opportunity and then copies them over to the relationships of the project. ( think anyway unless someone has a better idea).
Hi,
Thank you for your reply. I thoughtthat might be the case, I made the relationship but it doesnāt want to work. So I thought it might come down to a hook, unfortunately thats really not my field of expertise. Iāll reach out to a dev I use and see what they can do.
Thank you
Dan
Hereās what I use for my clients. Typically Iām copying custom relationships over on convert. But this could be adapted to your situation. You could customize the āifā condition for example to opportunity = won or somethingā¦
In the example heās copying over notes, but it could be modified to copy over contacts.
Hereās how Iāve used it for contacts:
<?php
/*************************************
Project: Relation Transfer
Original Dev: Angel MagaƱa, March 2012
@2012 Angel MagaƱa
cheleguanaco[at]cheleguanaco.com
Desc: Logic Hook for Transferring Relation
The contents of this file are governed by the GNU General Public License (GPL).
A copy of said license is available here: http://www.gnu.org/copyleft/gpl.html
This code is provided AS IS and WITHOUT WARRANTY OF ANY KIND.
*************************************/
class DataTransfer
{
function doDataTransfer($bean, $events, $arguments)
{
$action = $_REQUEST['action'];
if ($action == 'ConvertLead') //Must confirm it only triggers on conversion!!
{
$lead_id = $bean->id;
$contact_id = $bean->contact_id;
$bean->load_relationship('leads_contacts_1');
//Remove relationship
$rcontacts = array();
foreach ($bean->leads_contacts_1->getBeans() as $rcontact)
{
$rcontact_id = $rcontact->id;
$rcontacts[] = $rcontact_id;
$bean->leads_contacts_1->delete($lead_id, $rcontact_id);
}
//Transfer relationship to Contact record
$contact = new Contact();
$contact->retrieve($contact_id);
$contact->load_relationship('contacts_contacts_1');
foreach ($rcontacts as $rcontact)
{
$contact->contacts_contacts_1->add($rcontact);
}
}
}
}
?>
1 Like
Thatās great thank you Iāll have a go