Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error: calculate is undefined

(0) ShareShare
ReportReport
Posted on by

Hello-

My system is CRM 2011 Update RU 12 & RU 6.  I am trying to sum up several fields of currency into one field.  I am using the following js.  I keep getting an error with the field's customized event.  Field;cpdc_value1 Event:onchange Error:calculate is undefined.  Not sure how to correct this.

function calculate()

   {

   var value1 = Xrm.Page.entity.attributes.get['cpdc_value1'].getValue();

   var value2 = Xrm.Page.entity.attributes.get['cpdc_value2'].getValue();

   var value3 = Xrm.Page.entity.attributes.get['cpdc_value3'].getValue();

   var value4 = Xrm.Page.entity.attributes.get['cpdc_value4].getValue();

   var value5 = Xrm.Page.entity.attributes.get['cpdc_value5'].getValue(); 

   if(value1==null)return;
   if(value2==null)return;
   if(value3==null)return;
   if(value4==null)return;
   if(value5==null)return;

   var resulta = value1 + value2 + value3 + value4 + value5;

   Xrm.Page.entity.attributes.get['cpdc_resulta'].setValue(resulta) ;

   }

*This post is locked for comments

  • Verified answer
    RE: Error: calculate is undefined

    Me again... like always you are correct, I have a text field in there :(  

    Thank you for your wisdom and your willingness to share with those less knowledgeable.

  • RE: Error: calculate is undefined

    Hello Guido-

    Again what you suggested works perfectly.  Thank you!  Does this script only work for 5 attributes?  The script seems to throw an error when I add more than 5 rows.  Is there a limit on how many fields to calculate?

  • RE: Error: calculate is undefined

    Thank you Guido.  I just had one follow up question, if one of the value fields is blank the script does get results.  Is it possible to have the script just ignore any value fields with nothing entered?

  • RE: Error: calculate is undefined

    Thank you, it worked.  I guess I need more lessons on the proper syntax.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans