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

  • 0
  • 1
  • Question
  • Updated 4 weeks ago
  • Answered
  • (Edited)
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.
Photo of Christopher Knieste

Christopher Knieste

  • 174 Points 100 badge 2x thumb
  • like I thought I knew what I was doing but clearly don't

Posted 4 weeks ago

  • 0
  • 1
Photo of AustinK

AustinK

  • 854 Points 500 badge 2x thumb
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.
(Edited)
Photo of Christopher Knieste

Christopher Knieste

  • 174 Points 100 badge 2x thumb
CDATA did the trick!
You have to open and close the CDATA tag inside of the query tag. So basically:
<query>
    <![CDATA[. . .]]>
</query>