The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
Ok lets start:
1) First create some fields. For this demo I’ll use: val1, val2 and result
2) The calculation will be a simple multiplication. I’ll multiply val1 and val2 and output the result in the result field.
1: function calculate()
3: var val1 = Xrm.Page.entity.attributes.get['new_val1'].getValue();
4: var val2 = Xrm.Page.entity.attributes.get['new_val2'].getValue();
9: var result = val1 * val2;
Mind the new Xrm page model functions that I’m using. More information can be found on MSDN.
A little more information on the JScript. First I grab the data from both fields, check if they are not null and then do the actual calculation. Finally I set the result for the “calculated field”.
5) Add a new Web Resource. Here you can give a name, description etc. For the “type”, select Script (JScript). Finally click on the button “Text Editor” and add the code we’ve created above.
6) Once the Web Resource is created and published we can use it in our Account form where the custom fields are located.
7) Customize the form and select “Form Properties”. We first need to make the Web Resource available in this specific form.
8 ) Under the Events tab, add the Web Resource that we just created.
9) All that’s left to do is to configure the onChange events for the two fields and we’re done. Doubleclick on the field val1 and val2, go to the Events tab and configure the onChange event. The final result for each field should look like this:
10) Publish the form and you’re ready for testing.
Business Applications communities