web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

is there a way for me to setMin/setMax value dynamically in JavaScript?

(0) ShareShare
ReportReport
Posted on by

I have a customer who's requirement is to only allow their users to enter values between two values (min/max), based on the selection of another field (optionset).  I need to dynamically change the min and max range.  I can see the number field allows me to getMin/Max, but I don't see a setter for this.  Anyone else done something like this?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at
    RE: is there a way for me to setMin/setMax value dynamically in JavaScript?

    Hi smoov01,

    You could create a Whole Number field with a large range of allowed values, and then create a JavaScript file that runs on change of the field. The JavaScript will need to check the value of the Option Set field, and based on this value, check that the value entered into the Whole Number field falls within the desired range. Once you have this information you can finish the JavaScript by deciding what happens when a value falls outside the range.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: is there a way for me to setMin/setMax value dynamically in JavaScript?

    I would suggest to write a JS function and register it on change the field which you want to set the max and min value.  In the js method check the optionset value and based on that then check min,max value . If it's does not  matches  with required max,min value then set the field value to null.

  • smoov01 Profile Picture
    on at
    RE: is there a way for me to setMin/setMax value dynamically in JavaScript?

    Thanks Sander, yeah I thought of those earlier on, however I was not able to configure the business rule to use greater than/less than operators, and the suggestion functionality did not meet the customers request.  they want the user to not be able to proceed if the value is not within the range.  I was hoping to surface the html min/max somehow and set those, but it doesn't look like I can do it.  

    Thanks

  • Sander Daudey Profile Picture
    370 on at
    RE: is there a way for me to setMin/setMax value dynamically in JavaScript?

    You could use a Business rule to check the value or use the suggestion functionality in a business rule.

    The min max values cannot be set dynamically, these are the min max values for the specific field on database level.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#3
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans