Format

Viewing 8 reply threads
  • Author
    Posts
    • #16494
      Todd Ingersoll
      Participant

      I’m displaying a read only view of a SPFieldNumber field. Is there a way to format with a comma thousands separator and no decimals?

      So what I’m looking for is: “2,800” and not “2800.00000000000” (like in my screenshot below). I’ve looked all over the forum and user guide but can’t seem to find how to format a number on a form.

      Attachments:
    • #16514
      Alexander Bautz
      Keymaster

      Hi,
      Which version of DFFS are you using? I believe I have fixed this issue earlier, but cannot find it in the change log – I might have forgot to add it.

      Alexander

    • #16516
      Todd Ingersoll
      Participant

      I’m using: Dynamic Forms for SharePoint DFFS Backend v4.4.2.9|CSS version: 4.21 / |spjs-utility version: 1.279

    • #16524
      Artaker
      Participant

      Hi,

      I have a similar issue with a currency field. I guess it’s not taking working with the region settings of the site/SharePoint?

      Thanks

      Best regards,
      Nicole

    • #16538
      Todd Ingersoll
      Participant

      So it appears to display a number correctly when an entry exists for the column on form load. But when entering data in the edit or new form, and using a cascading dropdown for instance, it does not display correctly until the data is saved to the list.

    • #16541
      Alexander Bautz
      Keymaster

      Hi,
      How is it you pull the data into this field? – is it a regular number field that you set to readonly after typing into it? – how are you using it with the cascading dropdown functionality?

      Alexander

      • #16553
        Todd Ingersoll
        Participant

        1. I am successfully pulling in TargetP1 from a source list using the Cascading dropdown functionality. In the source list I am using a calculated column to convert a number I need to into text (because you don’t allow numbers to be used in the Cascading dropdown functionality). 2. Then I am attempting to convert the text to a number using a rule. This is where I can’t seem to find a way to display it with a thousands separator and no decimals in the New or Edit form. It displays properly in the view form (see the screenshot in my first post).

    • #16586
      Alexander Bautz
      Keymaster

      I don’t have a built in function in DFFS, but I have one in the vLookup script you can use like this:

      spjs.vLookup.formatNumber("10000000",{"decimals":2,"decimalSeparator":".","thousandsSeparator":" "});

      This can be used by adding a function in the custom js like this:

      function convertStringToNumber(){
          var val = getFieldValue("TargetP1"), fVal = "";
          fVal = spjs.vLookup.formatNumber(val,{"decimals":2,"decimalSeparator":".","thousandsSeparator":" "});
          setFieldVal("Target",fVal);
      }

      Remove the “Set field value” section from the rule, and call the custom function instead.

      Let me know how this works out.

      Alexander

      • #16595
        Todd Ingersoll
        Participant

        Thanks Alexander.
        Is setFieldVal coming from somewhere else? I’m getting this error:

        error

        Attachments:
      • #16599
        Todd Ingersoll
        Participant

        I got the error to go away as I noticed you referred to that function as setFieldValue (with a “ue”) in another post here. I cannot get it to display or set that field, however.

    • #16676
      Todd Ingersoll
      Participant

      This is now working. Here’s what I have for Custom JS and I call when the Cascading Dropdown is chosen:

      
      
      }
      function convertStringToNumber(){
          var val = getFieldValue("TargetP1"), fVal = "";
          fVal = spjs.vLookup.formatNumber(val,{"decimals":0,"decimalSeparator":".","thousandsSeparator":","});
          setFieldValue("TargetNumP1",fVal);
      }
    • #16680
      Alexander Bautz
      Keymaster

      Sorry for the delay – I must have missed your reply.

      I’m glad you figured it out – and yes, it should have been “setFieldValue” and not “setFieldVal”.

      This function is part of spjs-utility.js.

      Best regards,
      Alexander

Viewing 8 reply threads
  • You must be logged in to reply to this topic.