<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The OnObjectValidate Trigger</title>
	<atom:link href="http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/feed/" rel="self" type="application/rss+xml" />
	<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/</link>
	<description>smart business solutions</description>
	<lastBuildDate>Fri, 18 May 2012 01:30:19 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-2005</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Thu, 18 Nov 2010 23:29:46 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-2005</guid>
		<description>Robin:

Definitely a matter of opinion, but I would classify that as &lt;a href=&quot;http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize&quot; rel=&quot;nofollow&quot;&gt;premature optimization&lt;/a&gt;.

Geoff</description>
		<content:encoded><![CDATA[<p>Robin:</p>
<p>Definitely a matter of opinion, but I would classify that as <a href="http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize" rel="nofollow">premature optimization</a>.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-2004</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Thu, 18 Nov 2010 18:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-2004</guid>
		<description>It always gets me that seasoned programmers will call the same function 2 times, 
first to check the results, 
second time to use the results

Isn’t it smarter to save the results in a variable, this way this function it only called once?

&lt;pre&gt;&lt;code&gt;
Set Variable [$SDR; value: SmartDate(Get(ActiveFieldContents))]
If [ Not IsEmpty($SDR) ]
Set Field [ $SDR ]
End If
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>It always gets me that seasoned programmers will call the same function 2 times,<br />
first to check the results,<br />
second time to use the results</p>
<p>Isn’t it smarter to save the results in a variable, this way this function it only called once?</p>
<pre><code>
Set Variable [$SDR; value: SmartDate(Get(ActiveFieldContents))]
If [ Not IsEmpty($SDR) ]
Set Field [ $SDR ]
End If
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1986</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Fri, 24 Sep 2010 16:51:54 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1986</guid>
		<description>Dave: Very cool. I didn&#039;t realize that. Thanks!

Tim: Absolutely. There are lots of ways to extend/improve the smart date function. Thanks for the tips!</description>
		<content:encoded><![CDATA[<p>Dave: Very cool. I didn&#8217;t realize that. Thanks!</p>
<p>Tim: Absolutely. There are lots of ways to extend/improve the smart date function. Thanks for the tips!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Anderson</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1984</link>
		<dc:creator>Tim Anderson</dc:creator>
		<pubDate>Fri, 24 Sep 2010 11:57:54 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1984</guid>
		<description>An update, 

how about this? 

&lt;pre&gt;&lt;code&gt;Let( 
[
val =   Get ( ActiveFieldContents );
vs=Substitute(val;[&quot;day&quot;;&quot;&quot;];[&quot; &quot;;&quot;¶&quot;]);
vd=Left(FilterValues ( vs; &quot;mon¶tue¶wed¶thu¶fri¶sat¶sun¶tues¶weds¶wednes¶thurs¶satur&quot; );3);
vm=Substitute(FilterValues ( vs; &quot;last¶next&quot; );&quot;¶&quot;;&quot;&quot;);

cd = Get(CurrentDate);
td=DayOfWeek(cd);
dn = Case(							// sets dayNumber based on value entered. if no match returns orginal value
		vd = &quot;sun&quot;; 1;
		vd = &quot;mon&quot;; 2;
		vd = &quot;tue&quot;; 3;
		vd = &quot;wed&quot;; 4;
		vd = &quot;thu&quot;; 5;
		vd = &quot;fri&quot;; 6;
		vd = &quot;sat&quot;; 7;
		val 							// rtn&#039;s original &#039;value&#039; if no match.
		);

isday=dn = Filter(dn;&quot;-123456789&quot;);
diff=If (isday;(Case( dn ? td;dn-td;7+dn-td)));
modMult = Case(vm=&quot;last&quot;;-1;vm=&quot;next&quot;;1;0)

];
Case(								// add other quick text values outside days above here
	dn = &quot;today&quot; or dn = &quot;tod&quot; or dn = &quot;to&quot; or dn = &quot;now&quot;; cd;
	dn = &quot;tomorrow&quot; or dn = &quot;tom&quot; or dn = &quot;tm&quot; or dn = &quot;t&quot;; cd + 1;
	dn = &quot;yesterday&quot; or dn = &quot;yes&quot; or dn = &quot;y&quot;; cd - 1;
	PatternCount(dn;&quot;week&quot;)&gt;0 ; cd + (7*modMult);
	PatternCount(dn;&quot;month&quot;)&gt;0 ; cd + (30*modMult);
	PatternCount(dn;&quot;year&quot;)&gt;0 ;cd + (365*modMult);
	isday=1; cd + diff +(7*modmult);   // If tod (x = 0) add 7 days. eg if Sun + user enters Sun, show&#039;s next Sun Date.
    
   	dn							// rtn&#039;s orginal &#039;value&#039; if no match. (then handled by FMPro validation or your script post OOValidate)
	)

)&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>An update, </p>
<p>how about this? </p>
<pre><code>Let(
[
val =   Get ( ActiveFieldContents );
vs=Substitute(val;["day";""];[" ";"¶"]);
vd=Left(FilterValues ( vs; "mon¶tue¶wed¶thu¶fri¶sat¶sun¶tues¶weds¶wednes¶thurs¶satur" );3);
vm=Substitute(FilterValues ( vs; "last¶next" );"¶";"");

cd = Get(CurrentDate);
td=DayOfWeek(cd);
dn = Case(							// sets dayNumber based on value entered. if no match returns orginal value
		vd = "sun"; 1;
		vd = "mon"; 2;
		vd = "tue"; 3;
		vd = "wed"; 4;
		vd = "thu"; 5;
		vd = "fri"; 6;
		vd = "sat"; 7;
		val 							// rtn's original 'value' if no match.
		);

isday=dn = Filter(dn;"-123456789");
diff=If (isday;(Case( dn ? td;dn-td;7+dn-td)));
modMult = Case(vm="last";-1;vm="next";1;0)

];
Case(								// add other quick text values outside days above here
	dn = "today" or dn = "tod" or dn = "to" or dn = "now"; cd;
	dn = "tomorrow" or dn = "tom" or dn = "tm" or dn = "t"; cd + 1;
	dn = "yesterday" or dn = "yes" or dn = "y"; cd - 1;
	PatternCount(dn;"week")&gt;0 ; cd + (7*modMult);
	PatternCount(dn;"month")&gt;0 ; cd + (30*modMult);
	PatternCount(dn;"year")&gt;0 ;cd + (365*modMult);
	isday=1; cd + diff +(7*modmult);   // If tod (x = 0) add 7 days. eg if Sun + user enters Sun, show's next Sun Date.

   	dn							// rtn's orginal 'value' if no match. (then handled by FMPro validation or your script post OOValidate)
	)

)</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Anderson</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1983</link>
		<dc:creator>Tim Anderson</dc:creator>
		<pubDate>Fri, 24 Sep 2010 07:12:39 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1983</guid>
		<description>Really clear Geoff, thank you.

Any reason you don&#039;t just use the first 3 letter of actual days? Other than someone entering something like &#039;wedding day&#039; I don&#039;t see an issue.

If you were wanting to allow for more options that started with those letters (can&#039;t think of any of the top of my head) then they would just need to be placed at the top of the list?

Eg

&lt;pre&gt;&lt;code&gt;SmartDate :=

let( val=left(value;3);
Case(
   value = &quot;today&quot;; Get(CurrentDate);
   value = &quot;tomorrow&quot;; Get(CurrentDate) + 1;
   value = &quot;yesterday&quot;; Get(CurrentDate) - 1;
   val = &quot;sun&quot;; DateOfDay ( 1 );
   val = &quot;mon&quot;; DateOfDay ( 2 );
   val = &quot;tue&quot;; DateOfDay ( 3 );
   val = &quot;wed&quot;; DateOfDay ( 4 );
   val = &quot;thu&quot;; DateOfDay ( 5 );
   val = &quot;fri&quot;; DateOfDay ( 6 );
   val = &quot;sat&quot;; DateOfDay ( 7 )
)
)&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Really clear Geoff, thank you.</p>
<p>Any reason you don&#8217;t just use the first 3 letter of actual days? Other than someone entering something like &#8216;wedding day&#8217; I don&#8217;t see an issue.</p>
<p>If you were wanting to allow for more options that started with those letters (can&#8217;t think of any of the top of my head) then they would just need to be placed at the top of the list?</p>
<p>Eg</p>
<pre><code>SmartDate :=

let( val=left(value;3);
Case(
   value = "today"; Get(CurrentDate);
   value = "tomorrow"; Get(CurrentDate) + 1;
   value = "yesterday"; Get(CurrentDate) - 1;
   val = "sun"; DateOfDay ( 1 );
   val = "mon"; DateOfDay ( 2 );
   val = "tue"; DateOfDay ( 3 );
   val = "wed"; DateOfDay ( 4 );
   val = "thu"; DateOfDay ( 5 );
   val = "fri"; DateOfDay ( 6 );
   val = "sat"; DateOfDay ( 7 )
)
)</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek Bastille</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1973</link>
		<dc:creator>Derek Bastille</dc:creator>
		<pubDate>Wed, 15 Sep 2010 01:30:02 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1973</guid>
		<description>Another neat tool for ye olde FMPro toolbox...  Thanks!

  Oh, and Bastille Day is definitely a pretty cool holiday ;-)</description>
		<content:encoded><![CDATA[<p>Another neat tool for ye olde FMPro toolbox&#8230;  Thanks!</p>
<p>  Oh, and Bastille Day is definitely a pretty cool holiday <img src='http://sixfriedrice.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Knight</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1969</link>
		<dc:creator>David Knight</dc:creator>
		<pubDate>Mon, 13 Sep 2010 01:50:48 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1969</guid>
		<description>Geoff,

Nicely done.  Another side benefit of OnObjectValidate...they&#039;re handy when editing portal records and you want to run a script after the data *changes*.  For instance tabbing through multiple line item quantities and adjusting them should update the invoice total.

OnObjectKeystroke runs with each keystroke (wasteful when typing in multiple digits)

OnObjectExit runs *every* time you exit a portal field.  Even when you don&#039;t change data. Excessive.

OnObjectSave won&#039;t fire until all portal rows have been exited and the parent record is &quot;saved&quot;, blowing any tab order thing you have going in the portal.

OnObjectValidate works great, only firing if the portal field has been modified and exited, but preserving the tab order.  Showed this at my dev con session.  It&#039;s a nice subtle distinction.</description>
		<content:encoded><![CDATA[<p>Geoff,</p>
<p>Nicely done.  Another side benefit of OnObjectValidate&#8230;they&#8217;re handy when editing portal records and you want to run a script after the data *changes*.  For instance tabbing through multiple line item quantities and adjusting them should update the invoice total.</p>
<p>OnObjectKeystroke runs with each keystroke (wasteful when typing in multiple digits)</p>
<p>OnObjectExit runs *every* time you exit a portal field.  Even when you don&#8217;t change data. Excessive.</p>
<p>OnObjectSave won&#8217;t fire until all portal rows have been exited and the parent record is &#8220;saved&#8221;, blowing any tab order thing you have going in the portal.</p>
<p>OnObjectValidate works great, only firing if the portal field has been modified and exited, but preserving the tab order.  Showed this at my dev con session.  It&#8217;s a nice subtle distinction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olly Groves</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1962</link>
		<dc:creator>Olly Groves</dc:creator>
		<pubDate>Sun, 05 Sep 2010 17:37:44 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1962</guid>
		<description>Hi Geoff/Corn.

Thanks, really useful stuff.  

experimented with it a bit.
- moved the two CF&#039;s into one which gives option of putting all logic in  single function script (not sure it&#039;s bullet proof but holding up for now)
- added few more shorthands to Geoff&#039;s Originals.

Made rough demo for myself. For anyone interested file here http://bit.ly/cRbNwu

Olly Groves</description>
		<content:encoded><![CDATA[<p>Hi Geoff/Corn.</p>
<p>Thanks, really useful stuff.  </p>
<p>experimented with it a bit.<br />
- moved the two CF&#8217;s into one which gives option of putting all logic in  single function script (not sure it&#8217;s bullet proof but holding up for now)<br />
- added few more shorthands to Geoff&#8217;s Originals.</p>
<p>Made rough demo for myself. For anyone interested file here <a href="http://bit.ly/cRbNwu" rel="nofollow">http://bit.ly/cRbNwu</a></p>
<p>Olly Groves</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1959</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Sat, 04 Sep 2010 19:19:47 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1959</guid>
		<description>Corn:

That is absolutely brilliant. Much cleaner and simpler. I &lt;em&gt;always&lt;/em&gt; forget &lt;code&gt;Set Field&lt;/code&gt; can work in this way. I revised the article to do it your way. Thanks!

Geoff</description>
		<content:encoded><![CDATA[<p>Corn:</p>
<p>That is absolutely brilliant. Much cleaner and simpler. I <em>always</em> forget <code>Set Field</code> can work in this way. I revised the article to do it your way. Thanks!</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: corn walker</title>
		<link>http://sixfriedrice.com/wp/the-onobjectvalidate-trigger/comment-page-1/#comment-1958</link>
		<dc:creator>corn walker</dc:creator>
		<pubDate>Sat, 04 Sep 2010 18:12:36 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=496#comment-1958</guid>
		<description>Great write up.

Since you already have your cursor in the field and the script is explicitly firing before you exit the field, could you not also use the SetField[] script step with no target field specified? This would avoid the whole passing the field name as a parameter issue, keeping it über-simple.

If [ Not IsEmpty(SmartDate(Get(ActiveFieldContents))) ]
   Set Field [ SmartDate(Get(ActiveFieldContents)) ]
End If</description>
		<content:encoded><![CDATA[<p>Great write up.</p>
<p>Since you already have your cursor in the field and the script is explicitly firing before you exit the field, could you not also use the SetField[] script step with no target field specified? This would avoid the whole passing the field name as a parameter issue, keeping it über-simple.</p>
<p>If [ Not IsEmpty(SmartDate(Get(ActiveFieldContents))) ]<br />
   Set Field [ SmartDate(Get(ActiveFieldContents)) ]<br />
End If</p>
]]></content:encoded>
	</item>
</channel>
</rss>

