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)

Trying to Create a 6 Digit Numeric Field without Decimals or Commas

(1) ShareShare
ReportReport
Posted on by

Is there any way I can create a field in CRM where it's maximum 6 digits but does not insert a comma?

I've tried with whole number with minimum value 0 and maximum 999999 but it always inserts a comma..

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Numeric fields will always have a comma by default, but you can change that in your regional settings.

    Go to System -> Administration -> System Settings.

    In System Settings, click on the Formats tab, and then click on the Customize button.

    In the Number tab on the Customize Regional Options, in the Digit Group, select the option that has no commas (shown below).

    numberdigitaloptions.png

    That should be it. Good luck.

  • CRM Learner 88 Profile Picture
    on at

    Could I have it be with both no commas and no decimals?  Basically this is an ID Number field where we want it to be all numeric.

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

    Not really. You need some sort of separator between them.

    The options are period, command or backslash.

    So you could have 123456789/123456

    If you need only numbers in this format, I would you a string field.

  • CRM Learner 88 Profile Picture
    on at

    So if I want a field that must be 6 numeric digits and don't want a comma or decimal to be accepted, what should I do? Is a string field part of configuration or is this getting into coding?

    Thanks for your help I really appreciate it.

  • Suggested answer
    Friyank Profile Picture
    944 on at

    you can use string type and use JavaScript function to validate input value

    var value = Xrm.Page.getAttribute("new_customnumerice").getValue();

    var regex = /^[0-9]{1,6}$/;  

     if( !regex.test(value ) ) {

    alert('false')

    }

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

    If the value is only 6 digits, you can use a whole number and make the changes the I specified above, but you have to consider that these changes are across the board, meaning, they will change it for all entities.

    I think your best bet is to you a string and set it to six characters. You can control the string using JavaScript that will only accept numeric values.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

    You can handle this with javascript. Follow these steps :

    1. Open up the form, where you want to apply this.

    2. Edit the form and Click Form Properties.

    events-tab1.jpg

    Form-Editor.jpg

    3. Click on Events tab and Select the event on which you want to run it.

    events-tab.jpg

    4. On Event Handlers Section, Click on Add button to add Function Name to be called on the selected Event.

    events-tab1.jpg

    5. then, Click on Edit Library button and Paste Your Javascript Code to validate value in the tetbox.

    6. Click OK.

    7. Click Save and Publish.

    Please mark my answer as verified, if it solves your query.

    Thanks.

  • CRM Learner 88 Profile Picture
    on at

    I've never written code before, is this something easy I can do within CRM or is visual studio needed?

  • Suggested answer
    prt33k Profile Picture
    6,907 on at

    You can go to Setting-administration->system Setting-> format and choose 'blank space' as Digit Group. This will make the comma go away however do note that this will get applied to all integer field.

    Ideally, a string should be used for ID since user also ask to have number with leading zeros etc in which case the numeric option will not fly.

    Thanks,

    Prateek

  • CRM Learner 88 Profile Picture
    on at

    Thank you for providing these steps!  It looks like we already have an "onLoad" function on this form.  When I click 'Add' there is a Library already populated in the field and it seems to use the same code as what is in there originally.

    Should I just delete the code that is there and paste in the new one?  Or should I paste this code into the existing one we have already at the bottom past what is already there?

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