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)

Calculation of Minimum Value

(0) ShareShare
ReportReport
Posted on by 108

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

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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)

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

    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.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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).

    1351.business_5F00_rule.png

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    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);

          }

      }

    }

  • Poornimaa Profile Picture
    108 on at

    Thank you, Ravi Kashyap. I created a field with the calculation logic and it is working fine. !! Your help is much appreciated. :)

  • Poornimaa Profile Picture
    108 on at

    And, thanks to everyone for the suggestions. :)

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans