web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript to sum Qty field

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Jharana Baliyar Singh Profile Picture
    2,667 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
    4 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,

  • JohnAnonymous Profile Picture
    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
    6,212 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
    JohnAnonymous Profile Picture
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans