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

Notifications

Announcements

No record found.

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)
  • Sander Daudey Profile Picture
    370 on at

    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.

  • smoov01 Profile Picture
    on at

    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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    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.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans