locked
Whole Number Attribute Formatting in CRM RRS feed

  • Question

  • Hello,

      I've created a custom attribute of type whole number for storing a participant identification number (PIN). I saved my changes to the entity, added the attribute to the corresponding form and published the form.

    My problem is that after I create a new record and enter in my PIN number and save the record, the whole number is displayed with comma formatting. IE if my PIN number is 123456789, then what I'm seeing after I save the record is 123,456,789.

    I just want to see my PIN number as I typed it, not with the comma formatting. There does not seem to be any way to change the format mask for that field. Can anyone suggest how I can change or disable the format mask for this field?

    Or do I have to recreate the field to have a type of "single line of text"?

    Thanks.

    Monday, June 13, 2011 11:06 PM

Answers

  • You must create it as a text attribute, otherwise it  will use the number formatting that is selected for the attribute. You could change the number format in the organization/personal settings but then it would affect *every* number attribute in the system...

    Do you have a reason why you don't want to use the "single line of text"? You can then add JavaScript if you want to validate that the field contains only digit characters.


    Gonzalo | gonzaloruizcrm.blogspot.com

    Monday, June 13, 2011 11:08 PM
    Moderator

All replies

  • You must create it as a text attribute, otherwise it  will use the number formatting that is selected for the attribute. You could change the number format in the organization/personal settings but then it would affect *every* number attribute in the system...

    Do you have a reason why you don't want to use the "single line of text"? You can then add JavaScript if you want to validate that the field contains only digit characters.


    Gonzalo | gonzaloruizcrm.blogspot.com

    Monday, June 13, 2011 11:08 PM
    Moderator
  • Hi,

    I am agreed with Ruiz on this you can use text field and can apply validation for the same

    you can refer http://www.xrm.sk/blog/2010/12/crm-4-0-field-validation-allow-users-type-only-numbers/


    Mahain : My Dynamics CRM Blog
    Tuesday, June 14, 2011 1:43 AM
    Moderator
  • Hi Gonzalo,

     

    Can you give me an example of the JavaScript to format a Whole number to not have comas.  I have an attribute that does have Workflows linked to generate an auto-number and populate the field.  I don't want to have to go back an recreate everything for a formatting change if I don't have to.

     

    Thanks,

    Valerie


    Valerie Lingen
    Thursday, June 23, 2011 3:16 PM
  • You can find tons of javascripts to validate that a string is numeric if you search on Google. This is an example:

    function IsNumeric(strString)
      // check for valid numeric strings	
      {
      var strValidChars = "0123456789.-";
      var strChar;
      var blnResult = true;
    
      if (strString.length == 0) return false;
    
      // test strString consists of valid characters listed above
      for (i = 0; i < strString.length && blnResult == true; i++)
       {
       strChar = strString.charAt(i);
       if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
       }
      return blnResult;
      }
    
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Thursday, June 23, 2011 4:06 PM
    Moderator
  • just be aware that when you search around that not all javascript will always work as jscript for CRM.  It's definitely a subset.
    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Thursday, June 23, 2011 6:18 PM
    Moderator
  • Thanks for the replies. I just discovered I didn't have an email address configured to receive alerts (such as your replies to my post).

    I'll use a simple line of text.

    Though ultimately I would like to be able to apply different format masks to numeric fields, but perhaps that will be addressed in a future version of CRM.

    Regards

    Wednesday, July 13, 2011 11:09 PM
  • Hi, I have a strange problem with duration format of whole number attribute. There are 3 fields of this type on my form and I want to use javascript to total the first two and write the result in 3rd. The problem is that if I have 90 minutes as a result(1,5 hours), the third field displays 2 hours. For some reason it rounds it. Any help would be appriciated.

    Thanks in advance


    Zarko
    Friday, July 15, 2011 10:18 AM
  • Hi Zare,

      By definition a whole number does not allow decimals. Therefore, in order to store your value of 1.5 hours in a whole number field, the system must round the number. Perhaps, you need to consider using a field of type Floating Point Number or Decimal Number for your third field.

    Regards

    Friday, July 15, 2011 5:07 PM
  • Hi, tnx for your effort, but decimal is only representation, Whole Number with format Duration takes number of minutes. I solved my problem and would like to share this small bug which I encoutered. If I set this field value to 90 minutes from javascript, the immediate representation is 2 hours, but when I save the form, 1,5 hours is set as it should. So, I put my javascript in the form's OnSave event.

    Regards


    Zarko
    Monday, July 18, 2011 7:24 AM