Hello,
I have a scenario to calculate the minimum of 2 fields and store it in another field. (i.e) There are 2 fields, Fees owed and Grant Amount.
if fees Owed = 1999 and Grant amount = 2000, I need to find min of both of these fields and populate the minimum value in another field called "Approved grant Amount".
(Eg)Fees Owed = 1999
Grant Amount = 2000
Approved Grant Amount = 1999 (This needs to get populate by itself when those 2 fields have value in it and this is the minimum of both fields).
Can we do this without Javascript code? or if this can be achieve only by javascript can I get sample code for it?
Many Thanks,
Poornimaa An
*This post is locked for comments
And, thanks to everyone for the suggestions. :)
Thank you, Ravi Kashyap. I created a field with the calculation logic and it is working fine. !! Your help is much appreciated. :)
Hi ,
try this
function SetminimumValue()
{
debugger;
var FeesOwed = Xrm.Page.getAttribute("new_feesowed").getValue();
var GrantAmount = Xrm.Page.getAttribute("new_grantamount ").getValue();
if (FeesOwed != null && GrantAmount != null)
{
if (FeesOwed > GrantAmount)
{
Xrm.Page.getAttribute("new_approvedgrantamount").setValue(GrantAmount);
}
else if (FeesOwed < GrantAmount)
{
Xrm.Page.getAttribute("new_approvedgrantamount").setValue(FeesOwed);
}
}
}
You can probably also use a Business Rule for the situation you are looking for.
If FeesOwed < GrantAmount
SetValue of New Field to GrantAmount
Else
SetValue of New Field to FeesOwed
See screenshot below (used Latitude fields, but logic is the same).
Hi,
Other option is to have Approved Grant Amount as a calculated field and have this as the calculation logic i.e. set the value which is lowest. Note that if you already have the Approved Grant Amount field created, you can use it as calculated field. for this you need to delete and recreate the field as calculated.
If you can't delete then best option is workflows as suggested above.
if the fields are numeric (whole number, decimal or float) you can use a simple crm workflow (triggered on the update of the two fields)
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156