Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Question about old CRM code vs. new CRM code

$
0
0

Very new guy here and not a programmer. I will be seeking a programmers help but want to flush out the problem first. We have a simple calculated field that shows the profit made on a sale (revenue-cost and another that shows the profit margin). The profit field is the end result calculation and is set to read only. Up until the time of the latest update (December 2012?) this was working, as far as I know. I was hired around that time as well. Here is the code for that field.

function Form_onsave()
{
   if (crmForm.all.new_totalleasepayment.DataValue!=null) {
      crmForm.all.new_totalleasepayment.ForceSubmit = true;
   }
   if (crmForm.all.new_estprofit.DataValue!=null) {
      crmForm.all.new_estprofit.ForceSubmit = true;
   }
   if (crmForm.all.new_estprofitmargin.DataValue!=null) {
      crmForm.all.new_estprofitmargin.ForceSubmit = true;
   }
}

function new_leadsource_onchange()
{
   crmSDKSample.filterChildField("new_leadsource", "new_leadsourcedetail");
}

function new_profit_onchange()
{
   var field1 = crmForm.all.new_salerevenue.DataValue;
   field1 = (field1==null ? 0 : field1);
   var field2 = crmForm.all.new_estcosts.DataValue;
   field2 = (field2==null ? 0 : field2);
   crmForm.all.new_estprofit.DataValue = field1 - field2;

   if (field1 != 0)
   {
     crmForm.all.new_estprofitmargin.DataValue = (field1-field2)/field1;
   }
   else
   {
     crmForm.all.new_estprofitmargin.DataValue = 0;
   }
}

I see posts saying that I should use the following code instead: Xrm.Page.data.entity.attributes.get("<fieldname>").setSubmitMode("always");

Once again, noob here, does this code get inserted into the same library as the existing code or do I need to create a new library. Can the XML code exist with the old javascript code?

Thanks for any assistance on this.

<input id="e4c6d88f-7b2d-44c1-b41c-07a2dc146c33_attachments" type="hidden" value="" />

Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>