Workflow Convert Opportunity to Project

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