Is there a way to use a reusable constant or expression rules instead of char(10) or char(13) function?

Certified Associate Developer

Is there a way to use a reusable constant or expression rules instead of char(10) or char(13) function directly in any expression/interface rules?

Example Code:


a!richTextDisplayField(
label: "",
labelPosition: "COLLAPSED",
value: a!richTextItem(text: "Hello " & char(10) &"world")
),

I need to replace Char(10) here with either a constant or expression rule, thanks.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You could store the result of char(10) in a constant, however I don't see the benefit.

    People mostly know what char(10) means.  Your constant, however, may be a little confusing to new developers.  And how can you follow naming conventions for constants or expressions and come up with anything that's fewer key presses than char(10)?

    Your main problem is that if someone changes a char(10), that one part is broken.  If someone changes an expression or a constant, it's broken absolutely everywhere that it gets used.  One of the worst design patterns I ever heard of was a global constant for false() and a global constant for true().  Imagine what one person could do to the application switching the global true() constant to false().

    Just use char(10).

  • 0
    Certified Lead Developer
    in reply to Dave Lewis
    You could store the result of char(10) in a constant

    How would you accomplish this?  I was like 90% sure it wasn't possible, but to double check I tried and was just able to do it by using the Update Constant smart service, which feels a little cumbersome (and i'm a little surprised it works, but i just confirmed it does).  But since it's not editable (or easily observable) in the UI, i'm not sure how good of an idea it may or may not be.

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I just figured when you set up the constant, where it says value you'd just type char(10) instead of "anything else as a string".

    But again the entire rest of my post is about how I don't see how it would be a good idea either.

    What's so bad about the char() function?  Why would you need to obscure that from developers?  char(10) is just 8 characters long.  What's more convenient than that?

  • 0
    Certified Lead Developer
    in reply to Dave Lewis
    I just figured when you set up the constant, where it says value you'd just type char(10)

    Issue here is that the value editor for a constant isn't expressionable - so if you did this you'd end up displaying literally "char(10)" to the user instead of a linebreak.

    What's so bad about the char() function?

    I tend to agree and was wondering this as well.

Reply Children
No Data