Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Model-driven powerapp field that is a sum of all previous records of another field.

(0) ShareShare
ReportReport
Posted on by 5

I have field named AMA that contains decimal values. I would to have another field AMAcum that aggregates all previous records of AMA.

See below table.

AMA |AMAcum
4 4
3 7
5 12
8 20
3 23
9 31
2 33

Regards

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Model-driven powerapp field that is a sum of all previous records of another field.

    Hi Bernard,
    Since you have created the OnChange event and published it, as Microsoft mentioned below, you just need to change the field value to trigger your js function.

    community348.png

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/events/attribute-onchange

    Best Regards,

    Leo

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Model-driven powerapp field that is a sum of all previous records of another field.

    Hi

    Once you created your web resource and uploaded and published to crm.

    As LeoAlt suggested, you have to add the script to the form, bind it to OnChange of Control ACM and then select the js file name and the onchange event function name.

  • EBS Hydros Profile Picture
    5 on at
    RE: Model-driven powerapp field that is a sum of all previous records of another field.

    Hi Leo,

    Thanks a lot for your help. I have created the OnChange Event handler as you guided. 

    However, I need some guidance on where and how to call the function.

    Regards

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Model-driven powerapp field that is a sum of all previous records of another field.

    Hi partner,

    You could do this by js code.

    Please add the following js code into your form properties and add the function to AMA field onchange event.

    function getAMAcum(executionContext){
        var AMA=executionContext.getFormContext().getAttribute("new_ama");
        var AMAvalue=AMA.getValue();
        var AMAcum=executionContext.getFormContext().getAttribute("new_amacum");
        var AMAcumValue=AMAcum.getValue();
        var finalnum=AMAvalue+AMAcumValue;
        executionContext.getFormContext().getAttribute("new_amacum").setValue(finalnum);
    }


    community345.png

    community347.png

    community344.png

    community345.png 

    Hope it helps.

    Best Regards,

    Leo

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans