How to escape ')#' inside a CSP Runtime Expression?
I have a csp page that is using embedded Runtime Expression (https://docs.intersystems.com/ens201817/csp/docbook/Doc.View.cls?KEY=RCS...) and within that expression I am using a $data() modulo 2 to look for root-level data elements (https://docs.intersystems.com/ens201817/csp/docbook/Doc.View.cls?KEY=RCO...).
E.g:
#($select($data(^ImportantFlag)#2:"Important!",1:"Normal"))#
However, my modulo sign (#) after the $data() call is seen as the ending tag for the runtime expression resulting in a broken compilation.
Does anyone know if there is a way to escape )# or just # in a CSP Runtime Expression? Or do I need to abandon the elegance of the approach and actually check for a return value of 1 or 11 to ensure top level data?
A simple space before the modulus operator will fix this:
(Note that I needed to add a closing brace for the $Select as well.) If you wish, you can add a few more spaces for readability. 😉
Thank you @Gertjan Klein - that did it! (note, I fixed the missing ) in my example ... obviously I wrote that in my browser and not my IDE ;) )
if you encounter another situation that you cannot add a space before the # you can do:
W #($select($data(^ImportantFlag)#2:"Important!",1:"Normal"))#
</server>