Announcements
No record found.
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
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
Hi Alekya,
You may want to have a look at OOTB Calculated field: technet.microsoft.com/.../dn832103.aspx
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");
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.
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){
else
var attribute1= field1; (a date value)
var attribute2= field2; (a date value)
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.