I’m looking to run batch APEX that parses my SKUID page XML for all of my SKUID pages and replaces certain object/variable names with other object/variable names (mass updating the skuid pages to convert from using one object to another object)
To do this I use APEX to query on each skuid__Page__c object and combine each skuid__Page__c object’s Layout fields into a single string for analysis / updating:
skuid__Layout__c
skuid__Layout2__c
skuid__Layout3__c
skuid__Layout4__c
skuid__Layout5__c
(note: SKUID stores the XML for their pages split between these 5 layout fields, each are 131072 character Long Text fields, and if the XML extends beyond 131071 characters it continues on to the next field to be stored … 655355 appears to be the limit for the number of characters in SKUID page XML)
When done updating my single unified string, I split the string up into 131071 character substrings and fill the Layout-Layout5 fields with them.
This seems to work great, except if one of these layout fields happens to start with a space character. If that happens, it looks as if SKUID has something that forces the layout field to be trimmed of leading spaces, and then when the XML is combined and opened by the SKUID editor it gives an invalid XML error. Testing the XML with an XML tester reveals the issue to be this trimmed space leaving XML that looks like this:
<skootable showexportbuttons="false"showsavecancel=“true”>
Where there should be a space after “false” this was trimmed on Layout5. Layout5 begins with showsavecancel. I tried even updating Layout5 to add the space in front and it was trimmed by SKUID when updated.
Why does SKUID trim the leading spaces here? Is there another way to go about this other than trying to force the string to not split at a point where there would be a space between Layout fields? Is there a better way to set these layout fields in APEX?
Thanks!