Discussions

Expand all | Collapse all

How do I encode ampersands located in an XML Do_Query field string so that they get properly decoded on Quickbase's end?

  • 1.  How do I encode ampersands located in an XML Do_Query field string so that they get properly decoded on Quickbase's end?

    Posted 04-24-2019 17:21
    I have an automated system that, when triggered, uses information associated with the trigger to run a query and update another record based on the result of that query.

    There are a few fields related to the query that contain ampersands (e.g. "System 1&2") that must be matched for the automation to work. If I attempt to send a message with the ampersand unescaped (e.g.{22.EX.'System 1&2}), it fails because it is invalid XML. If I try to replace the literal ampersand with escaped versions that should be valid XML (e.g. {22.EX.'System 1&2'}, {22.EX.'System 1&2'}) QuickBase returns no error, but the query doesn't find what I expect it to, ostensibly because the escape character isn't then decoded back into an ampersand on the other end.

    I searched and searched and couldn't find any guidance on this issue for QuickBase in particular because for other systems, these escape characters seem to work.

    Thanks in advance for your help! Hopefully someone knows how to get around this, aside from replacing all the ampersands in our tables with some XML-conforming substitute.


  • 2.  RE: How do I encode ampersands located in an XML Do_Query field string so that they get properly decoded on Quickbase's end?

    Posted 04-24-2019 17:58
    Have you tried to use CDATA?

    I'm not positive it will work perfectly for this but it sounds like it might.

    I guess you could try using & as well, just to check if that worked. Also %26, just because why not test it to be sure.

    What works in this exact situation might even be a combination of the above things. I've seen both CDATA and percent encoding be needed before in other things but I don't use XML much with QuickBase.


  • 3.  RE: How do I encode ampersands located in an XML Do_Query field string so that they get properly decoded on Quickbase's end?

    Posted 04-24-2019 18:57
    CDATA did the trick!
    You have to open and close the CDATA tag inside of the query tag. So basically:
    <query>     <![CDATA[. . .]]> </query>