Page 1 of 1

Errmsg with colors

Posted: May 13th, 2026, 5:12 pm
by mussabahire
Hello cspro users.
Is there a way we can format the error message with color?
Ex: errmsg("The EA is %v and total is:%v",EA,TOT);
And the results is like:
The EA is 11001 and total is:126

Re: Errmsg with colors

Posted: May 14th, 2026, 10:14 am
by Gregory Martin
The default errmsg does not support coloring text. However, you can achieve this behavior if you use your own custom errmsg dialog. See here for the overview:

https://www.csprousers.org/help/CSPro/h ... %20Dialogs

The attached application demonstrates this. What I did was:

1) The dialog uses Mustache to render the message: {{message}}. Mustache will escape for HTML text in {{ }} but not in {{{ }}}, so I changed {{message}} -> {{{message}}}

2) I added an Action Invoker access token so that the dialog is allowed without prompting. See here: https://www.csprousers.org/help/CSPro/a ... token.html

3) I used HTML in the errmsg text:
errmsg("We are going to color this value in blue: <span style=\"color:blue\">%v</span>", VALUE);
Note that if you use this, anytime you use a HTML reserved character in an error message, you would need to escape it. If you don't, you could break the HTML that renders the error message. For example, for safety, this is how you would escape a < character and a text fill:
errmsg("%s, aged &lt; 12, cannot be married.", encode(NAME));
colored-errmsgs.zip