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 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
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.
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
}
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.
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");
Hi Alekya,
You may want to have a look at OOTB Calculated field: technet.microsoft.com/.../dn832103.aspx
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156