I am getting the below-mentioned error while converting xml to cdt using torecord() function.
Does any one know what is the root cause of this error ?? or Let me know alternatives of converting XML to CDT ?
Thanks
Discussion posts and replies are publicly visible
Hi Akash,
I am not quit sure about the logic that you are using. Please see this documentation this might help to fix your issue. https://docs.appian.com/suite/help/22.1/fnc_scripting_torecord.html
Hi Naresh,
Thanks for your reply. But I have followed the same torecord( xml, type ).
Is SearchInquiryResponse the name of your CDT that you're trying to convert to? Also are there any special characters in the value you're trying to convert?
I'd suggest trying to remove parts of your XML until you get to a state that works - there's probably a certain tag or structure that is incorrect and it may take some trial and error to find which one is the culprit.
Hi Peter,
Thanks for your reply. Yes, SearchInquiryResponse is the name of my CDT. I'll try the trial and error way, for now, to find out the issue.
Peter Lewis, There is a special character ampersand(&) in the XML which is causing this error.
Can you please let me know how to handle this scenario as my XML might contain special characters as well ?
Is there any way to handle it and convert them to XML escaped format?
Where is the XML getting generated? The text being passed into the XML's data will need to be sanitized so that parsing it later doesn't break (similar things happen, for instance, if these unsanitized characters are passed into the MS Word from Template smart service). The sanitization rule I always use looks something like this:
a!localVariables( local!characters: { "&", ">", "<", """", /* quote */ "'", /* apostrophe */ char(10), char(13) }, /* the ordering of these is important. */ local!replacements: { tohtml("&"), tohtml(">"), tohtml("<"), "\&\quot;", "\&\apos;", -- note: backslashes added here just to post on Community "\&\#10;", "" }, reduce( fn!substitute, trim(ri!input), a!forEach( local!characters, { fv!item, local!replacements[fv!index] } ) ) )