Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Javascript to sum Qty field

Posted on by Microsoft Employee

Hello all, is there a way to sum values using javascript?

There is a custom Batch Number which can have products. The same product can be in different Batch, but the code below is only getting the latest Qty value, I need to sum them.

*This post is locked for comments

  • Verified answer
    Jharana Baliyar Singh Profile Picture
    Jharana Baliyar Singh 2,665 on at
    RE: Javascript to sum Qty field

    Hi Tekwise,

    You can use Rollup fields for ur requirements.

    Plz have a look around below link:

    www.softwareanswers.co.uk/.../aggregate-calculations-in-microsoft-dynamics-crm-2015.html

    Thanks,

  • Verified answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Javascript to sum Qty field

    Hi Tekwise,

    I would suggest using a rollup field for what you are trying to accomplish here if you have a 1-N relationship between the Product and the Batch.  You should be able to do this in CRM without any custom code.

    Hope this helps.

    Thanks,

  • M.T. Eikelenboom Profile Picture
    M.T. Eikelenboom 5,241 on at
    RE: Javascript to sum Qty field

    Did any of the responses help? If not, any questions? If so, could you please mark an answer as verified?

  • Verified answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Javascript to sum Qty field

    Create a Qty in the global variable

    Create a query for product entity filter by product number.

    Iterate the collection of return value from the above the query

    Qty += result.quantity;

  • Verified answer
    M.T. Eikelenboom Profile Picture
    M.T. Eikelenboom 5,241 on at
    RE: Javascript to sum Qty field

    I don't understand your question completely, but it should be the following process:

    1. Create a variable to store your Qty

    2. Create a query that returns all applicable product / batch combinations

    3. Iterate over the collection results and add the Qty from on record to the variable created under 1.

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