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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Summing values using javascript and getting error "Cannot read property 'getValue' of null"

(0) ShareShare
ReportReport
Posted on by 50

Hello!

I have 7 currency value fields displayed on the opportunity form that I need rolled up into the Potential Rollup currency field. Using the javascript below I'm receiving an error of: "Cannot read property 'getValue' of null". Whether I have a value in one of the fields or not it continues to give me the error and subsequently cannot get a rollup of values in the potential rollup field. 

function CalculateValues() {
var sumRollup=
Xrm.Page.getAttribute("sone_Value1").getValue() +
Xrm.Page.getAttribute("sone_Value2").getValue() +
Xrm.Page.getAttribute("sone_Value3").getValue() +
Xrm.Page.getAttribute("sone_Value4").getValue() +
Xrm.Page.getAttribute("sone_Value5").getValue() +
Xrm.Page.getAttribute("sone_Value6").getValue() +
Xrm.Page.getAttribute("sone_Value7").getValue();
Xrm.Page.getAttribute("sone_PotentialRollup").setValue(sumRollup);
}

I have also tried this script, and it returns the same error.

function CalculateValues() {

 

   var value1 = Xrm.Page.getAttribute("sone_Value1").getValue();

 

   var value2 = Xrm.Page.getAttribute("sone_Value2").getValue();

 

   var value3 = Xrm.Page.getAttribute("sone_Value3").getValue();

 

   var value4 = Xrm.Page.getAttribute("sone_Value4").getValue();

 

   var value5 = Xrm.Page.getAttribute("sone_Value5").getValue();

 

   var value6 = Xrm.Page.getAttribute("sone_Value6").getValue();

 

   var value7 = Xrm.Page.getAttribute("sone_Value7").getValue();

 

   var sumRollup = value1 + value2 + value3 + value4 + value5 + value6 + value7;

 

   // alert(sumRollup);

 

   Xrm.Page.getAttribute("sone_PotentialRollup").setValue(sumRollup);

 

}

Any recommendations or insights would be greatly appreciated. 

I was recently solving this using a business rule, but it started creating an incremental loop rather than just summing the values. 

I have the same question (0)
  • Verified answer
    Charan Raju C R Profile Picture
    7 Moderator on at

    Hi Sarah,

    1. Check if all the fields (7+1) are placed on the form
    2. Verify the field names are correct. Also ensure the fields' logical names are used, not schema names in the javascript
    3. Debug javascript to identify which line or which field retrieval causing the error
  • SarahC Profile Picture
    50 on at

    Thank you! That was exactly my issue. I was using the schema name, such a small minor fix, but made all the difference and significantly easier than the previous business rule.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 166 Super User 2026 Season 1

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 51 Most Valuable Professional

#2
NeerajPawar Profile Picture

NeerajPawar 51

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans