Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Calculated fields onChange event - Javascript

Posted on by 873

Hello,

How do we extract the values of the calculated fields OnChange event of the fields in real-time through Javascript?
Calculated-Fields.png

My main goal is to populate those calculated values in different custom fields, as well as perform different actions.

In addition, is it possible to update the calculated fields through Power Automate?

Could you please provide an example of the steps needed to achieve the above requirements?

Any help is greatly appreciated.

Best regards,
EBMRay

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calculated fields onChange event - Javascript

    Hi EBMRay,

    Yes, this could work.

    Sample Code:

    function onload(executionContext){
    	var formContext = executionContext.getFormContext();
    	var totaltax = formContext.getAttribute("totaltax").getValue();
    	formContext.getAttribute("cr1bc_customtotaltax").setValue(totaltax);
    }
    

    Result:

    pastedimage1656322376507v1.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calculated fields onChange event - Javascript

    Hi EBMRay,

    "OnLoad or OnSave event of the form, is it possible to extract their values and populate them in the custom fields I want by using the syntax below?

    formContext.getAttribute(arg).getValue()

    Or even on both events that will not work?"

    This should work, I would have a try.

  • EBMRay Profile Picture
    EBMRay 873 on at
    RE: Calculated fields onChange event - Javascript

    Hi ,

    OnLoad or OnSave event of the form, is it possible to extract their values and populate them in the custom fields I want by using the syntax below?

    formContext.getAttribute(arg).getValue()

    Or even on both events that will not work?

    Awaiting your response.

    Best regards,

    EBMRay

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Calculated fields onChange event - Javascript

    Hi EBMRay,

    How do we extract the values of the calculated fields OnChange event of the fields in real-time through Javascript?

    In addition, is it possible to update the calculated fields through Power Automate?

    Neither of them could not be achieved. If you want to do some customization with these fields, you would better create some custom fields to replace them.

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans