Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Rollup field getValue removes decimals

Posted on by Microsoft Employee

Hello,

I have a rollup field, When i recalculate it and i do a getValue of the field the decimal places are removed:
This field is used to calculate the open invoice amount. Meaning that the value will now be wrong.

Current result:
 
Total amount = 100.50
Payments received: 100.50
Open amount: 0.50 because the Payments received are returned as 100 instead of 100.50

Payments-received.png

Is there any other function i need to call to get the correct result?

Thanks in advance,

Sincerely,

Joey

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup field getValue removes decimals

    Hello Scott,

    I tried this in the correct window and still get the wrong value. The field is a Currency field. I can try to create a new field as decimal and see if it will works then.

    I'll keep you informed.

  • Suggested answer
    ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Rollup field getValue removes decimals

    I've just tried this on one of my instances (btw you must change the drop down to 'ClientApiWrapper.aspx') and I get the correct decimal value before and after a refresh. I don't know why you are not getting the decimal value -what version of Dynamics are you using? Since the code you are using is correct - it would suggest that it is a bug and you should raise it with Microsoft.

  • ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Rollup field getValue removes decimals

    When running scripts against the page - you need to change the Target drop down to the correct context.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup field getValue removes decimals

    Gopalan,

    I set it to other field and debugged te value in console.log.

    Result: 2,487.00 and in debug console 2487

    I think i will just read out the full text (including the currency sign) and then replace that with nothing. I have no other choice i think. It's hack fixing but I need this to work.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup field getValue removes decimals

    Hello Scrott,

    When i run:

    var val1 = Xrm.Page.getAttribute("lit_total_payments_received").getValue();

    In the Console of IE I get the message:

    Unable to get property 'getValue' of undefined or null reference

    I tried it with other fields and I still get the null reference error. Do i need to call the function getValue differently from outside my JS file? Something like parent.Xrm.Page?

  • Gee Bee Profile Picture
    Gee Bee 11,397 on at
    RE: Rollup field getValue removes decimals

    Hi

    This should work fine.

    Debug the code and find out the value for val1 in watch, before executing alert statement.

    Or set this value to another field in the form, and find out whether the decimals are truncated.

  • ScottDurow Profile Picture
    ScottDurow 50,177 on at
    RE: Rollup field getValue removes decimals

    Hi Joey,

    Interesting! That code looks fine. What value do you get if you just run the getValue in the console debugger rather than the on change?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup field getValue removes decimals

    Dear Nithya,

    Thanks for this but I do not want to recalculate using javascript. I want the recalculated value to be correct in the onchange event after i recalculate the field using the recalculate button.

    Thanks.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Rollup field getValue removes decimals

    Hello Scott,

    The thing I do is calling the getValue in the onchange event of the Total Payments Received field. which is triggered when the field is recalculated.

    function lit_total_payments_received_onchange()

    {

    var val1 = Xrm.Page.getAttribute("lit_total_payments_received").getValue();

    alert('Total payments received: ' + val1);

    }

    val1 will be 2487 instead of 2487.20

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Rollup field getValue removes decimals

    Hi Joey,

    See: community.dynamics.com/.../215980

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans