<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>SugarCRM Forums - Sales Force Automation</title>
		<link>http://forums.sugarcrm.com/</link>
		<description>Application design and requirements discussion</description>
		<language>en</language>
		<lastBuildDate>Thu, 20 Jun 2013 01:40:04 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://forums.sugarcrm.com/images/misc/rss.png</url>
			<title>SugarCRM Forums - Sales Force Automation</title>
			<link>http://forums.sugarcrm.com/</link>
		</image>
		<item>
			<title>Simple Logic hook, sending 2 emails ERROR</title>
			<link>http://forums.sugarcrm.com/f29/simple-logic-hook-sending-2-emails-error-87027/</link>
			<pubDate>Tue, 28 May 2013 20:56:29 GMT</pubDate>
			<description><![CDATA[Hi SugarCRM community, i am new on this big new world of developing for SugarCRM, i created a logic hook that trigger "before_safe", all works great but when the logic_hook sends the email it sends two emails, First without information and  Second with the information required. 
 
Example: 
 
Using...]]></description>
			<content:encoded><![CDATA[<div>Hi SugarCRM community, i am new on this big new world of developing for SugarCRM, i created a logic hook that trigger &quot;before_safe&quot;, all works great but when the logic_hook sends the email it sends two emails, First without information and  Second with the information required.<br />
<br />
Example:<br />
<br />
Using the opportunity module, the logic hook send me an email when a change in Sales Stage ocure.<br />
<br />
First Email:<br />
<br />
   The opportunnity has change its Sales Stage from to<br />
<br />
Second email<br />
<br />
    The opportunnity has change its state Sales Stage from Needs Analysis to Negotiation/Review<br />
<br />
<br />
<br />
This is my code:<br />
<br />
<br />
logic_hook.php<br />
<br />
<br />
$hook_array = Array(); <br />
// position, file, function <br />
$hook_array['before_save'] = Array(); <br />
$hook_array['before_save'][] = Array(1, 'Opportunities push feed', 'modules/Opportunities/SugarFeeds/OppFeed.php','OppFeed', 'pushFeed');<br />
$hook_array['before_save'][] = Array(2, 'State change', 'include/Netcom/CheckStatus.php', 'CheckStatus', 'Checkstatus');<br />
$hook_array['after_ui_frame'] = Array(); <br />
$hook_array['after_ui_frame'][] = Array(1, 'Opportunities InsideView frame', 'modules/Connectors/connectors/sources/ext/rest/insideview/InsideViewLogicHook.php','InsideViewLogicHook', 'showFrame'); <br />
<br />
<br />
CheckStatus.php<br />
<br />
&lt;?php<br />
	if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); <br />
	require_once('modules/Opportunities/Opportunity.php');<br />
	require_once('data/SugarBean.php');<br />
	require_once('include/entryPoint.php');<br />
	include_once('include/SugarPHPMailer.php');<br />
	include_once('include/utils/db_utils.php');<br />
	include_once('custom/include/netcom/funciones.php');<br />
	<br />
	class CheckStatus<br />
	{<br />
		function Checkstatus(&amp;$bean, $event, $arguments)<br />
		{<br />
			<br />
			<br />
			$funciones = new funciones();<br />
			$txt = &quot;The opportunnity has change its state &quot;.$bean-&gt;fetched_row['sales_stage'].&quot; to &quot;.$bean-&gt;sales_stage.&quot;.&quot;;<br />
			$funciones-&gt;SendMail($txt);<br />
		}<br />
	}<br />
?&gt;<br />
<br />
<br />
Thank you for your help.<br />
<br />
<br />
@spidersab</div>

]]></content:encoded>
			<category domain="http://forums.sugarcrm.com/f29/">Sales Force Automation</category>
			<dc:creator>spidersab</dc:creator>
			<guid isPermaLink="true">http://forums.sugarcrm.com/f29/simple-logic-hook-sending-2-emails-error-87027/</guid>
		</item>
	</channel>
</rss>
