How do I escape double-quotes (") in my formfield data? For Eg. nested macro expressions

VarQUERY can be used as an alternative to VarSEARCH or VarFORMAT's $formfield() FormatTokens (Eg. by replacing $formfield(MyField) with $percntQUERY{'$web.$topic'/MyField}$percnt)

VarQUERY can also often be used in place of VarFORMFIELD and VarMETA.

VarQUERY has a style parameter which understands a few different serialisation formats, one of them is json which automatically takes care of escaping any quotes (") in the content. Compare:

%FORMFIELD{"TopicTitle"}%
Test:
How do I escape double-quotes (") in my formfield data? For Eg. nested macro expressions

vs

%QUERY{"TopicTitle" style="json"}%
Test:
"How do I escape double-quotes (\") in my formfield data? For Eg. nested macro expressions"

You can make VarQUERY extract data from a topic other than the topic in which it's written by using the / reference operator (see QuerySearch syntax), Eg.:

%QUERY{"'Support.Faq40'/TopicTitle" style="json"}%
Test:
"How do I re-write =DBQUERY= as =SEARCH{type=\"query\"}=?"

IDEA! style="json" results in a valid JSON fragment, i.e. it returns a string quoted in double-quotes. Be mindful of this when replacing Eg. VarFORMFIELD macros

BasicForm edit

TopicClassification FrequentlyAskedQuestion
Topic Summary Explains the QUERY macro style parameter as a way to escape quotes in DataForms content
Extension
Interested Parties
Related Topics BestPracticeTip27
Topic revision: r1 - 19 Apr 2012, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy