<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sir Slur &#187; entity total</title>
	<atom:link href="http://www.sirslur.com/tag/entity-total/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sirslur.com</link>
	<description>Slinging around some technology stuff</description>
	<lastBuildDate>Mon, 24 Oct 2011 20:44:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>MS CRM 4 &#8211; Custom Entity Product Total</title>
		<link>http://www.sirslur.com/2009/07/28/ms-crm-4-custom-entity-product-total/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.sirslur.com/2009/07/28/ms-crm-4-custom-entity-product-total/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 15:23:26 +0000</pubDate>
		<dc:creator>sirslur</dc:creator>
				<category><![CDATA[MS CRM]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[custom entity product total]]></category>
		<category><![CDATA[custom entity total]]></category>
		<category><![CDATA[entity total]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ms crm 4]]></category>

		<guid isPermaLink="false">http://www.sirslur.com/2009/07/28/ms-crm-4-custom-entity-product-total/</guid>
		<description><![CDATA[I have been working on a custom entity inside of CRM.  Basically, I was adding product to it and wanted to get the price per unit for the correct price list, multiply it by the quantity and apply any discount.  This functionality works great in the quote section, and I needed to duplicate it.  Well, [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a custom entity inside of CRM.  Basically, I was adding product to it and wanted to get the price per unit for the correct price list, multiply it by the quantity and apply any discount.  This functionality works great in the quote section, and I needed to duplicate it.  Well, I did and I did it all in JavaScript.  I did not have to create a plug-in, which could also be done.  Here is how I did it:<span id="more-98"></span></p>
<p>//this is to get the proudctid guid<br />
var product = document.crmForm.all.new_productid;<br />
//this is to determine if I have chosen to set my own price per unit<br />
var work = crmForm.all.new_overrideprice.value;</p>
<p>var product2 = new Array();<br />
product2 = product.DataValue;</p>
<p>var productID = product2[0].id;</p>
<p>var product4 = productID;<br />
//this is where I stop getting the productid guid</p>
<p>//this is me setting the default pricelist to a var, <br />
//if you want to dynamicly set the pricelist you would need to do a search on it like I do for the product<br />
var pl = &#8220;{C5987A92-DADB-DC11-9F47-001143E82CB3}&#8221;;<br />
if (productID!=null)<br />
{<br />
    //set your own error check<br />
}</p>
<p>if (work == &#8217;1&#8242;)<br />
{</p>
<p>// Prepare variables to retrieve the figures.<br />
var authenticationHeader = GenerateAuthenticationHeader();</p>
<p>// Prepare the SOAP message.<br />
var xml = &#8220;&lt;?xml version=&#8217;1.0&#8242; encoding=&#8217;utf-8&#8242;?&gt;&#8221;+<br />
&#8220;&lt;soap:Envelope xmlns:soap=&#8217;<a href="http://schemas.xmlsoap.org/soap/envelope/'&quot;+">http://schemas.xmlsoap.org/soap/envelope/&#8217;&#8221;+</a><br />
&#8221; xmlns:xsi=&#8217;<a href="http://www.w3.org/2001/XMLSchema-instance'&quot;+">http://www.w3.org/2001/XMLSchema-instance&#8217;&#8221;+</a><br />
&#8221; xmlns:xsd=&#8217;<a href="http://www.w3.org/2001/XMLSchema'">http://www.w3.org/2001/XMLSchema&#8217;</a>&gt;&#8221;+<br />
authenticationHeader+<br />
&#8220;&lt;soap:Body&gt;&#8221;+<br />
&#8220;&lt;RetrieveMultiple xmlns=&#8217;<a href="http://schemas.microsoft.com/crm/2007/WebServices'">http://schemas.microsoft.com/crm/2007/WebServices&#8217;</a>&gt;&#8221;+<br />
&#8220;&lt;query xmlns:q1=&#8217;<a href="http://schemas.microsoft.com/crm/2006/Query'&quot;+">http://schemas.microsoft.com/crm/2006/Query&#8217;&#8221;+</a><br />
&#8221; xsi:type=&#8217;q1:QueryExpression&#8217;&gt;&#8221;+<br />
&#8220;&lt;q1:EntityName&gt;productpricelevel&lt;/q1:EntityName&gt;&#8221;+<br />
&#8220;&lt;q1:ColumnSet xsi:type=&#8217;q1:ColumnSet&#8217;&gt;&#8221;+<br />
&#8220;&lt;q1:Attributes&gt;&#8221;+<br />
&#8220;&lt;q1:Attribute&gt;amount&lt;/q1:Attribute&gt;&#8221;+<br />
&#8220;&lt;/q1:Attributes&gt;&#8221;+<br />
&#8220;&lt;/q1:ColumnSet&gt;&#8221;+<br />
&#8220;&lt;q1:Distinct&gt;false&lt;/q1:Distinct&gt;&#8221;+<br />
&#8220;&lt;q1:Criteria&gt;&#8221;+<br />
&#8220;&lt;q1:FilterOperator&gt;And&lt;/q1:FilterOperator&gt;&#8221;+<br />
&#8220;&lt;q1:Conditions&gt;&#8221;+<br />
&#8220;&lt;q1:Condition&gt;&#8221;+<br />
&#8220;&lt;q1:AttributeName&gt;pricelevelid&lt;/q1:AttributeName&gt;&#8221;+<br />
&#8220;&lt;q1:Operator&gt;Equal&lt;/q1:Operator&gt;&#8221;+<br />
&#8220;&lt;q1:Values&gt;&#8221;+<br />
&#8220;&lt;q1:Value xsi:type=&#8217;xsd:string&#8217;&gt;&#8221;+pl+&#8221;&lt;/q1:Value&gt;&#8221;+<br />
&#8220;&lt;/q1:Values&gt;&#8221;+<br />
&#8220;&lt;/q1:Condition&gt;&#8221;+<br />
&#8220;&lt;/q1:Conditions&gt;&#8221;+<br />
&#8220;&lt;q1:FilterOperator&gt;And&lt;/q1:FilterOperator&gt;&#8221;+<br />
&#8220;&lt;q1:Conditions&gt;&#8221;+<br />
&#8220;&lt;q1:Condition&gt;&#8221;+<br />
&#8220;&lt;q1:AttributeName&gt;productid&lt;/q1:AttributeName&gt;&#8221;+<br />
&#8220;&lt;q1:Operator&gt;Equal&lt;/q1:Operator&gt;&#8221;+<br />
&#8220;&lt;q1:Values&gt;&#8221;+<br />
&#8220;&lt;q1:Value xsi:type=&#8217;xsd:string&#8217;&gt;&#8221;+product4+&#8221;&lt;/q1:Value&gt;&#8221;+<br />
&#8220;&lt;/q1:Values&gt;&#8221;+<br />
&#8220;&lt;/q1:Condition&gt;&#8221;+<br />
&#8220;&lt;/q1:Conditions&gt;&#8221;+<br />
&#8220;&lt;/q1:Criteria&gt;&#8221;+<br />
&#8220;&lt;/query&gt;&#8221;+<br />
&#8220;&lt;/RetrieveMultiple&gt;&#8221;+<br />
&#8220;&lt;/soap:Body&gt;&#8221;+<br />
&#8220;&lt;/soap:Envelope&gt;&#8221;;<br />
// Prepare the xmlHttpObject and send the request.<br />
var xHReq = new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;);<br />
xHReq.Open(&#8220;POST&#8221;, &#8220;/mscrmservices/2007/CrmService.asmx&#8221;, false);<br />
xHReq.setRequestHeader(&#8220;SOAPAction&#8221;,&#8221;<a href="http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple&quot;);">http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple&#8221;);</a><br />
xHReq.setRequestHeader(&#8220;Content-Type&#8221;, &#8220;text/xml; charset=utf-8&#8243;);<br />
xHReq.setRequestHeader(&#8220;Content-Length&#8221;, xml.length);<br />
xHReq.send(xml);<br />
// Capture the result.<br />
var resultXml = xHReq.responseXML;</p>
<p>// Check for errors.<br />
var errorCount = resultXml.selectNodes(&#8216;//error&#8217;).length;<br />
if (errorCount != 0)<br />
{<br />
var msg = resultXml.selectSingleNode(&#8216;//description&#8217;).nodeTypedValue;<br />
alert(msg);<br />
}<br />
// Parse and display the results.<br />
else<br />
{<br />
var results = resultXml.getElementsByTagName(&#8216;BusinessEntity&#8217;);<br />
var msg = &#8220;&#8221;;<br />
if (results.length == 0)<br />
{<br />
  msg = &#8220;No item was found.&#8221;;<br />
  alert(msg);<br />
  return;<br />
}<br />
else<br />
{<br />
    for (i=0;i &lt; results.length;i++)<br />
    {<br />
     var amount = results[i].selectSingleNode(&#8216;./q1:amount&#8217;).nodeTypedValue;<br />
     crmForm.all.new_priceperunit.value = amount;<br />
    }  <br />
}<br />
}<br />
    //this is where I take my 3 fields and add them together if I have not chosen to override the system price<br />
    var pri = parseInt(crmForm.all.new_priceperunit.value.replace(/,/g, &#8221;));<br />
    var qt = parseInt(crmForm.all.new_quantity.value.replace(/,/g, &#8221;));<br />
    var di = parseInt(crmForm.all.new_discount.value.replace(/,/g, &#8221;));<br />
    var total = ((pri  * qt) &#8211; di);<br />
    crmForm.all.new_amount.value = total;<br />
}<br />
else<br />
{<br />
    //this is where I take my 3 fields and add them together if I have chosen to override the system price<br />
    var price = (crmForm.all.new_priceperunit.value.replace(/,/g, &#8221;));<br />
    var qut = (crmForm.all.new_quantity.value.replace(/,/g, &#8221;));<br />
    var dis = (crmForm.all.new_discount.value.replace(/,/g, &#8221;));<br />
    //set the total field amount<br />
    var tot = ((price * qut) &#8211; dis);<br />
    crmForm.all.new_amount.value = tot;</p>
<p>}</p>
<p> </p>
<p>I hope this helps some of you.</p>
<p>l8r</p>
<p><map name='google_ad_map_98_c392d43f49786b8a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/98?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_98_c392d43f49786b8a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=98&amp;url= http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F' /></p>
<div class="sociable">
<div class="sociable_tagline">
<strong>Share</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;bodytext=I%20have%20been%20working%20on%20a%20custom%20entity%20inside%20of%20CRM.%C2%A0%20Basically%2C%20I%20was%20adding%20product%20to%20it%20and%20wanted%20to%20get%20the%20price%20per%20unit%20for%20the%20correct%20price%20list%2C%20multiply%20it%20by%20the%20quantity%20and%20apply%20any%20discount.%C2%A0%20This%20functionality%20works%20great%20in%20the" title="Digg"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;notes=I%20have%20been%20working%20on%20a%20custom%20entity%20inside%20of%20CRM.%C2%A0%20Basically%2C%20I%20was%20adding%20product%20to%20it%20and%20wanted%20to%20get%20the%20price%20per%20unit%20for%20the%20correct%20price%20list%2C%20multiply%20it%20by%20the%20quantity%20and%20apply%20any%20discount.%C2%A0%20This%20functionality%20works%20great%20in%20the" title="del.icio.us"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;t=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total" title="Facebook"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total" title="Mixx"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;annotation=I%20have%20been%20working%20on%20a%20custom%20entity%20inside%20of%20CRM.%C2%A0%20Basically%2C%20I%20was%20adding%20product%20to%20it%20and%20wanted%20to%20get%20the%20price%20per%20unit%20for%20the%20correct%20price%20list%2C%20multiply%20it%20by%20the%20quantity%20and%20apply%20any%20discount.%C2%A0%20This%20functionality%20works%20great%20in%20the" title="Google Bookmarks"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total" title="Reddit"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F" title="Slashdot"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total" title="StumbleUpon"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F" title="Technorati"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;submitHeadline=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;submitSummary=I%20have%20been%20working%20on%20a%20custom%20entity%20inside%20of%20CRM.%C2%A0%20Basically%2C%20I%20was%20adding%20product%20to%20it%20and%20wanted%20to%20get%20the%20price%20per%20unit%20for%20the%20correct%20price%20list%2C%20multiply%20it%20by%20the%20quantity%20and%20apply%20any%20discount.%C2%A0%20This%20functionality%20works%20great%20in%20the&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total&amp;body=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F" title="email"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F&amp;title=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total" title="Live"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=MS%20CRM%204%20%26ndash%3B%20Custom%20Entity%20Product%20Total%20-%20http%3A%2F%2Fwww.sirslur.com%2F2009%2F07%2F28%2Fms-crm-4-custom-entity-product-total%2F" title="Twitter"><img src="http://www.sirslur.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sirslur.com/2009/07/28/ms-crm-4-custom-entity-product-total/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

