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

Javascript recurrence function help

(0) ShareShare
ReportReport
Posted on by

I have a function which calculates amount taking two dates booking from and booking to.

I want to use the same function to calculate the amount taking two new fields.

*This post is locked for comments

I have the same question (0)
  • Clem Profile Picture
    2,541 on at

    Can you please give us a bit more details of what you are trying to achieve ?

    If i got it right, you have 2 parameters : From and To and based on these 2 dates, you calculates the amount of money for all opportunities opened or closed during this time frame ?

    What do you mean by "two new fields" ? two new dates ?

    Regards,

    Clément

  • Suggested answer
    khoait Profile Picture
    452 on at

    Hi Alekya,

    You may want to have a look at OOTB Calculated field: technet.microsoft.com/.../dn832103.aspx

  • ashlega Profile Picture
    34,477 on at

    Are you asking how to pass parameters?

    function CalcData(field1, field2)

    {

       var attribute1= Xrm.Page.getAttribute(field1);

       var attribute2= Xrm.Page.getAttribute(field2);

       //Do the calculations

    }

    Then call it with different field names:

    CalcData("new_field1", "new_field2");

  • Community Member Profile Picture
    on at

    Yes, I have another field of called Reschedule, If it is yes we are asking the user to enter two new dates to and from. I want to calculate the amount using the same function by sending new dates.

  • Suggested answer
    Clem Profile Picture
    2,541 on at

    if your initial function looks like the one posted by Alex.

    You can add an extra parameter, something like :

    function CalcData(field1, field2, isField = true)

    {

    if(isField){

      var attribute1= Xrm.Page.getAttribute(field1);

      var attribute2= Xrm.Page.getAttribute(field2);

    }

    else

    var attribute1= field1; (a date value)

       var attribute2= field2; (a date value)

      //Do the calculations

    }

  • Sindre Wetting Profile Picture
    on at

    If you're planning on having different output fields for this date calculation you could add a third parameter for output, so that your function would look something like this:

    function CalculateDays(start, end, output)


    If you'r on v9 you should also pass the execution context as the first parameter.

    function CalculateDays(executionContext, start, end, output)

    Xrm.Page-model is deprecated, and using the execution context is the the way to do this properly.

    OOTB Calculated fields as suggested by Khoa Nguyen is also a good option as it is a no-code solution.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans