CommCare – How to Use Text Formatting in Hidden Values

commcare

I'm trying to set up text that is being generated in a hidden value and is going to be displayed via a label, can I set up that hidden value to include text formatting so when the hidden value is displayed in a label certain text will be bold?

Best Answer

Text formatting is performed with Markdown, so it must be applied after any data that's being loaded has been injected into the question's text. I've used constructs like

This appointment is: **#form/days_late** days late

and they've worked correctly.

That would mean that what gets "formatted" is the text of the question after everything is loaded, so it shouldn't matter whether

days_late = '**3**' and you output #case/days_late Days Late

or

days_late = '3' and you output **#case/days_late** Days Late

since what ultimately gets formatted is the result:

**3** Days Late

Keep in mind that everywhere you output that label will include the markdown, so you might want to save two copies of the text (one formatted one not) depending on where it will be used.

Edit:

I just tried this and noticed that the form won't necessarily apply markdown by default unless it detects that you are trying to use it.

If you don't see Turn Off Text Formatting next to the question where you are displaying the value you can trigger markdown on a question by putting in something like

**test**

into the question text and then removing it, after which it should stay on until/unless disabled manually.