Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

not able to do the addition of currency fields

(0) ShareShare
ReportReport
Posted on by 2,385

Hi,

I have written some code in javasript.

function calculateVehicleCost ()
{
var id =Xrm.Page.data.entity.getId();

var odataSelect = "/" + Xrm.Page.context.getOrgUniqueName() + "/XRMServices/2011/OrganizationData.svc" + "/" + "new_vehiclesSet?$filter=new_opportunity/Id eq guid'" + id + "'";

$.ajax(
{
type: "GET",
async: false,
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataSelect,
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest) {
var cost = null;
for (var i = 0 ; i < data.d.results.length; i++)
{
alert (data.d.results[i].new_CostperVehicle.Value);
cost = cost + data.d.results[i].new_CostperVehicle.Value;
}
alert (cost);
Xrm.Page.getAttribute("new_cost").setValue(cost);
//Xrm.Page.getAttribute("new_cost").setValue(parseFloat(eval(cost)));

Xrm.Page.data.entity.attributes.get("new_cost").setSubmitMode("always");
},
error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + textStatus + errorThrown + odataSelect); }
}
);
}

but the cost variable showing value "null1.00001.0000"

It is not doing addition of null+1.0000+1.000 and just appends one string to another.

Is there loophole in code or any other way to do this.

Thanks 

Dilip

*This post is locked for comments

  • gawasdilip Profile Picture
    gawasdilip 2,385 on at
    RE: not able to do the addition of currency fields

    Thanks Guido

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans