<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lead conversion fails (except it doesn&amp;#39;t)</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1211/lead-conversion-fails-except-it-doesn-t</link><description>Greetings developers, I have been trying to make this code work but it is making the Lead conversion show that it fails when in fact it was sucessful. I have created on contact a Field of List type . It contains the types of opportunities a contact wishes</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4902?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 18:36:33 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:27dd8df6-80ba-47fe-ba9c-ee38398cc04f</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;Your title says &amp;quot;Lead conversion fails (except it doesn&amp;#39;t)&amp;quot; so I assumed this error is when a lead is converted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4904?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 18:35:39 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:c11e5b8e-0e3f-4c43-b555-9b27cf192372</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;When you convert a lead, do you have an option to also create an Opportunity?&lt;/p&gt;&lt;p&gt;I may be mistaken, it may be a customization we have.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4903?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 17:41:44 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:3d3bde7c-1ff6-4226-99e3-ebd282504a3d</guid><dc:creator>Giovanni Marazzi</dc:creator><description>&lt;p&gt;Why Lead conversion creates a New Opportunity? Where is it shown?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4901?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 17:36:02 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:e76a5f8f-9e4f-4af8-ab29-3b0c312ffc31</guid><dc:creator>Giovanni Marazzi</dc:creator><description>&lt;p&gt;Thanks so much.&lt;/p&gt;&lt;p&gt;I didn&amp;#39;t know anything about lead conversion. I didn&amp;#39;t find it anywhere (besides your post on customization of it).&lt;/p&gt;&lt;p&gt;I don&amp;#39;t use prepared statements because everytime i tried it didn&amp;#39;t work. It is still a mystery to me how to do things on it like sub querys or even inner join with a query result.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4900?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 14:27:42 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:bfde5ff6-a64d-4850-9c0d-6648fb973347</guid><dc:creator>Francesca Shiekh</dc:creator><description>&lt;p&gt;A couple of observations:&lt;/p&gt;&lt;p&gt;Your SQL is not a prepared statement, see:&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Data_Framework/Database/DBManager/" rel="nofollow" target="_blank"&gt;http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Data_Framework/Database/DBManager/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Also, when you convert the lead, you create a new Opportunity.&lt;/p&gt;&lt;p&gt;It looks like you hook is a before save on Opportunities.&lt;/p&gt;&lt;p&gt;If the Opportunity is new, and it has not been saved yet,&amp;nbsp;your&amp;nbsp;opportunity will not have an id yet.&lt;/p&gt;&lt;p&gt;So&amp;nbsp;&lt;/p&gt;&lt;pre class="" style="color:#000000;background:#f5f2f0;border:0px;margin:0.5em 0px;padding:1em 1em 1em 3.8em;"&gt;&lt;code style="border:0px;font-weight:inherit;"&gt;&lt;span class="" style="border:0px;font-weight:inherit;"&gt;&lt;span class="" style="color:#ee9900;border:0px;font-weight:inherit;"&gt;$id_opp&lt;/span&gt; &lt;span class="" style="color:#a67f59;background:rgba(255, 255, 255, 0.5);border:0px;font-weight:inherit;"&gt;=&lt;/span&gt; &lt;span class="" style="color:#ee9900;border:0px;font-weight:inherit;"&gt;$bean&lt;/span&gt;&lt;span class="" style="color:#a67f59;background:rgba(255, 255, 255, 0.5);border:0px;font-weight:inherit;"&gt;-&lt;/span&gt;&lt;span class="" style="color:#a67f59;background:rgba(255, 255, 255, 0.5);border:0px;font-weight:inherit;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="" style="color:#990000;border:0px;font-weight:inherit;"&gt;id&lt;/span&gt;&lt;span class="" style="color:#999999;border:0px;font-weight:inherit;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;will not be set. That&amp;#39;s why you have to save twice, the first time the id is generated, the second time you save, the id can be retrieved because the opportunity already exists.&lt;/p&gt;&lt;p&gt;I suggest you change this to an after save logic hook on opportunities and use the beans to retrieve the related contact instead of sql:&lt;/p&gt;&lt;p&gt;&lt;a href="http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_8.0/Data_Framework/Models/SugarBean/index.html#Fetching_Related_Records" rel="nofollow" target="_blank"&gt;http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_8.0/Data_Framework/Models/SugarBean/inde&amp;hellip;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Hope this helps,&lt;br /&gt;FrancescaS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lead conversion fails (except it doesn't)</title><link>https://sugarclub.sugarcrm.com/thread/4899?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 12:19:07 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:eba679d3-a201-42be-8c9b-119926b92745</guid><dc:creator>Giovanni Marazzi</dc:creator><description>&lt;p&gt;Anyone?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>