This topic contains 4 replies, has 0 voices, and was last updated by michoel 8 years, 10 months ago.

  • Author
    Posts
  • #2927

    GAJ

    Appreciate your help on the syntax to remove a dash or add a percent sign to an incoming discount amount that could be either an actual amount, or a percentage amount.

    For example the discount may be -10.00 (meaning dollars) or 10 (meaning percentage).

    If -10.00 the result s/be 10.00.

    If 10, the result s/be 10%.

    Easy stuff if one knows the syntax.

    Very much appreciate the help.
    This is a cached copy. Click here to see the original post.

  • #2928

    al3xicon

    I would use REGEXP_REPLACE and leverage regular expressions:

    REGEXP_REPLACE(‘test-te%st-‘, ‘[-%]’, ”) // returns “testtest”

    You can also do nested REPLACE statements as such:

    REPLACE(REPLACE(‘test-te%st-‘, ‘%’, ”), ‘-‘, ”)

  • #2929

    GAJ

    Thanks al3xicon… very much appreciated.

    Yet, a followup question please is how would you code this inside either an

    Invoice PDF/HTML Template

    line, e.g. ${record.???}

    , or in a

    Custom Transaction Body Field’s DEFAULT VALUE/Formula field?

    Sorry I have to ask. I’ve limited trial-and-error time on this and have to throw it out here.

    Gary

  • #2930

    al3xicon

    I see…unfortunately I have never done this in a template, however I wonder if you can use the method described here: https://netsuite.custhelp.com/app/an…il/a_id/13622/. It may look something like this:

    No idea if that will work, but may be worth a shot.

  • #2931

    michoel

    You can do this in a template with the ‘replace’ builtin, e.g.

    Code:
    ${record.field?replace(‘%’, ”)?replace(‘-‘,”)}

    Sorry I have to ask. I’ve limited trial-and-error time on this and have to throw it out here.

    There is nothing to apologise for, that’s what this forum is for

You must be logged in to reply to this topic.