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 :
Microsoft Dynamics CRM (Archived)

JavaScript code wont execute in Dynamics CRM

(0) ShareShare
ReportReport
Posted on by 320

Hello,

I am trying to run the following code:

function RevenueTotal
{
var sumRevenue=
Xrm.Page.getAttribute("new_estimatedservicestotal").getValue() +
Xrm.Page.getAttribute("new_estimatedlicensestotal").getValue() +
Xrm.Page.getAttribute("new_estimatedalftotal").getValue() +
Xrm.Page.getAttribute("new_cloudpublic").getValue() +
Xrm.Page.getAttribute("new_dedicatedsupport").getValue() +
Xrm.Page.getAttribute("new_solutionspecificsupport").getValue() +
Xrm.Page.getAttribute("new_thirdpartysupport").getValue() +
Xrm.Page.getAttribute("new_customsupport").getValue();
Xrm.Page.getAttribute("new_estimatedrevenue").setValue(sumRevenue);
}

Checked the syntax, published it a couple of times, still showing an error.

The code is pretty simple (Addition of few fields). Checked the name of the fields as well. 

This code runs under onSave method of the form. There are 3 other scripts. They run fine.

Can someone tell me why the code wont run?

Thank you.

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Whats the error you are getting?

  • Huzefa Bootwala Profile Picture
    320 on at

    Hello,

    ReferenceError: RevenueTotal is not defined

       at eval (eval at RunHandlerInternal (abc/form/ClientApiWrapper.aspx?ver=1310006179:153:1), <anonymous>:1:1)

       at RunHandlerInternal (abc/form/ClientApiWrapper.aspx?ver=1310006179:157:1)

       at RunHandlers (abc/form/ClientApiWrapper.aspx?ver=1310006179:116:1)

       at ExecuteHandler (abc/form/ClientApiWrapper.aspx?ver=1310006179:79:1)

       at Mscrm.TurboForm.Control.CustomScriptsManager.$Cb_1 (abc/_static/form/formcontrols.js?ver=1310006179:3310:100)

       at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandler (abc/_static/form/formcontrols.js?ver=1310006179:3256:18)

       at Mscrm.TurboForm.Control.CustomScriptsManager.executeHandlerByDescriptor (abc/_static/form/formcontrols.js?ver=1310006179:3287:18)

       at abc/_static/form/formcontrols.js?ver=1310006179:3295:19

       at abc/_common/global.ashx?ver=1310006179:4024:149269

       at Mscrm.TurboForm.Control.Data.DataEntity.$Dd_1 (abc/_static/form/formcontrols.js?ver=1310006179:13139:13)

    This is the error.

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    There is a syntax error in your code. You are missing "()" after the method name i.e.

    =============

    function RevenueTotal()

    {

    var sumRevenue=

    Xrm.Page.getAttribute("new_estimatedservicestotal").getValue() +

    Xrm.Page.getAttribute("new_estimatedlicensestotal").getValue() +

    Xrm.Page.getAttribute("new_estimatedalftotal").getValue() +

    Xrm.Page.getAttribute("new_cloudpublic").getValue() +

    Xrm.Page.getAttribute("new_dedicatedsupport").getValue() +

    Xrm.Page.getAttribute("new_solutionspecificsupport").getValue() +

    Xrm.Page.getAttribute("new_thirdpartysupport").getValue() +

    Xrm.Page.getAttribute("new_customsupport").getValue();

       Xrm.Page.getAttribute("new_estimatedrevenue").setValue(sumRevenue);

    }

    ==================

    For future reference, you can use this online JS syntax validator. It seems very good-

    esprima.org/.../validate.html

  • Huzefa Bootwala Profile Picture
    320 on at

    Hello,

    Sorry. My bad.

    Thanx so much for your time.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans