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

Notifications

Announcements

No record found.

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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 144 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 59

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans