locked
Crm 2013 + To remove comma from Whole Number field RRS feed

  • Question

  • Hi,

    I have a field on my form of type "Whole Number". I want to remove comma from the field and display simple number. I know there exists a System Setting to remove comma however it will apply to all the fields i want to do it one only my current field.
    Any Supported or UnSupported code will help. I tried some unsupported code too .
    However this didn't work for me.

    var number = Xrm.Page.data.entity.attributes.get("new_numberfield").getValue();
                    if(number !=null)
                        document.getElementById('new_numberfield').value = number;

    Any help would be appreciated.

    Thanks,


    Monday, May 11, 2015 7:03 AM

All replies

  • There is no simple way to do this. One alternative would be to create a text field, and use plugins or workflow to populate this with the value of the number field, and only display the text field. This approach works reasonably well if the user will not subsequently edit the field, but is a lot harder if you  need to allow changes to the data via the text field

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Monday, May 11, 2015 8:29 AM
    Moderator
  • Hey

    Thanks for the reply.

    I dont want to recreate the field (as per the requirement). Also the field is editable. Even if there is any unsupported way please suggest.

    Monday, May 11, 2015 9:21 AM
  • Hi Nancy,

           Lot of work but this is what you can do.

    Create a new text field and copy the value to this text field in javascript. Validate that only numerical values are entered in the text field. If the whole number field is needed to perform some calculations, make sure updated text field values are copied to whole number field in On Change field event.

            This is fully supported but is additional work. You can leave the whole number field in the background as not visible on the form.

    Hope this helps.
      
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

     

    Monday, May 11, 2015 10:19 AM
  • If the whole number field already contains value how should i update  the textfield ?

    Can u provide some code for more clarification.

    Monday, May 11, 2015 10:51 AM
  • Hi Nancy,

        Depends on how many records have data. If there are more than few thousand, it would be better to write a simple update code. For that you can use the sample code from the following MSDN link:

    https://msdn.microsoft.com/en-us/library/gg328416.aspx?f=255&MSPPError=-2147217396

         If there is only few thousand records, you can write a workflow which executes on update of any field and use the trick mentioned here:

    http://www.zero2ten.com/blog/executing-workflows-for-more-than-250-records-in-microsoft-dynamics-crm-2011/

    Hope this helps.
      
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

     

    Tuesday, May 12, 2015 9:53 AM
  • Hi,

    The free workflow executor is also worth a look and can throttle to minimise asynchronous overload http://www.gapconsulting.co.uk/our-solutions/free-tools/workflow-executor

    Back to the original requirement however, personally I would push back to the business on this requirement because you're incurring quite a lot of effort for what amounts to a cosmetic issue and will never show a return on investment. Your effort will continue to increase if you use an unsupported approach as you'll be faced with re-work costs in your future upgrade projects.

    Rob


    MCTS. GAP Consulting Ltd. Microsoft Community Contributor Award 2011 & 2013

    Tuesday, May 12, 2015 9:34 PM