Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to remove the , (comma) from Whole Number fields?

Posted on by Microsoft Employee

Does anyone know of a way to remove the comma from Whole Number fields? This relates specifically to when you are using a 4-digit Whole Number field for entering in a Year.

1256.2018_2D00_03_2D00_06_5F00_8_2D00_17_2D00_10.png

I know that you can change the display options on both a system level, and on a personal preference level, and remove the comma separator. However this also removes the comma from currency, and my users are unwilling to accept that as a compromise.

I have looked at switching to a 4-character free text field, and using JS to validate the text in the fields onChange, and deliver an error message when the text is entered in, or if the number does not contain four digits. However, I am having problems with removing the field level notification once the correct data is entered, which will only confuse the users.

Here's the JS I've used for anyone thats interested.

function buildCheck() {

var buildYear = Xrm.Page.getAttribute("ahoy_build_year").getValue();

Xrm.Page.getControl("ahoy_build_year").clearNotification("a");
Xrm.Page.getControl("ahoy_build_year").clearNotification("b");

if(!Number(buildYear)){
Xrm.Page.getControl("ahoy_build_year").setNotification("Please enter valid year","a");
Xrm.Page.getAttribute("ahoy_build_year").setValue("");

} else if(buildYear && buildYear.length != 4) {
Xrm.Page.getControl("ahoy_build_year").setNotification("Please enter a 4-digit number (YYYY)","b");
Xrm.Page.getAttribute("ahoy_build_year").setValue("");
}

}
I have done a heap of googling, and have found that a lot of people have this same problem, but there is no universal way of solving it.
Does anyone know if there is a solution from a third party provider that could get around this?
Thanks in advance for any feedback or advice.

*This post is locked for comments

  • Suggested answer
    unizap Profile Picture
    unizap on at
    RE: How to remove the , (comma) from Whole Number fields?

    Hi,

    You may also try input masks on Single Line Text Fields for validating the input. See link below.

    docs.microsoft.com/.../additional-controls-for-dynamics-365-for-phones-and-tablets

  • Suggested answer
    Michael Ual Profile Picture
    Michael Ual on at
    RE: How to remove the , (comma) from Whole Number fields?

    This is a bit late, but have you considered using a custom entity for year?  If users can only relate the year but not create new records, you won't have to validate on data entry.  And as another advantage over using a free text field, you can add a second value to your custom entity to track the year as a whole number in addition to the commaless display, which will allow you to perform addition search / sort functions, such as "year > 2013".

  • awalters Profile Picture
    awalters 3,079 on at
    RE: How to remove the , (comma) from Whole Number fields?

    We actually ended up using an entity for years in circumstances where it's a reasonably limited number of years (i.e. anything you'd feel comfortable putting in a drop down).  Hack-y, but so is everything else.  They really need to allow masking for specific fields.  :-(

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to remove the , (comma) from Whole Number fields?

    Thanks for tip. Will give it a shot later this arvo.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to remove the , (comma) from Whole Number fields?

    Hi ,

    First of all for whole Number field there is only global format you need to change and it will change in whole application.

    In this scenario  better to use single line text what you written here.

    Seems you have not put your whole code here .please follow the step-

    //Clear notification

    If ( numeric )

    {

       If (length ==4)

        {

              //Clear notification

              // Set focus to next field.

         }

          Else

         {

               //Set notification

               // Set field null

         }

    }

    Else{

       //Set notification

        // Set field null

    }

    Hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans