3

I'm using Custom Labels in a component. I'd like to make one of my labels, myCustomLabel_Heading, optional; you can add it if you like, but it's not required as part of the content.

When I go to edit myCustomLabel_Heading in Custom Labels, Salesforce tells me that the label value is required. Is there a way to save a Custom Label so the value is empty?

I'm using aura:unescapedHtml to render the Custom Labels. Using a   as the value of myCustomLabel_Heading renders an empty space. Ideally I'd like nothing rendered at all (no value in my Custom Label).

1
  • Value of custom label is required, you could add an aura:if condition before the unescapedHtml to hide if the label contains the default value. Seems like you want to achieve the functionality provided by design parameters, is this component not exposed to app builder?
    – Raul
    Jun 30 '20 at 23:10
4

On occasions where I've needed this, I've always just set it to the Zero Width Space (U+200B). Amazingly, Salesforce supports this as a valid character to save, and it has no width (exactly 0 pixels). You can copy it from "​", although it may be hard to grab. You can also copy it from this page, which is how I copied it (there's an input field you can copy from, just click in it, Ctrl-A, Ctrl-C, and then Ctrl-V into Salesforce). Alternatively, since you're using unescaped HTML, ​ may also serve your use case.

1
  • Great to learn about this, thanks for sharing!
    – Raul
    Jun 30 '20 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.