Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Calculate Using JS. in crm form

$
0
0

The following is the code i have written & getting the error on form load "Unhandled Exception: System.ServiceModel.FaultException`1" & getting error  "Cannot read property 'setValue' of null" on field load

function Experience()
{

var sDate = Xrm.Page.getAttribute("new_startdate");
var eDate = Xrm.Page.getAttribute("new_enddate");

if (typeof (sDate) != undefined && sDate != null && typeof (eDate) != undefined && eDate != null)
{

var startDate = new Date(Xrm.Page.getAttribute("new_startdate").getValue());
var endDate = new Date(Xrm.Page.getAttribute("new_enddate").getValue());
if(endDate < startDate )
{
alert("End date should not be less than Start date.");
}
else
{
var currentDate = new Date();
var difference = Math.floor(endDate.getTime() - startDate.getTime());
var days = ((difference % 31536000000) % 2628000000)/86400000;
var months = (difference % 31536000000) / 2628000000;
var years = difference / 31536000000;

var result = (Math.floor(years) + "." + Math.floor(months));
Xrm.Page.getAttribute("new_totalexperince").setValue(parseFloat(result));

}

}

}


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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