Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've run into an issue with CMSImport trashing data that I can't find any workaround for - we have a Textbox field on Members which is used to store a JSON string (it doesn't need to be anything fancier than that).
This all works fine normally, but when importing member data using CMSImport what appears in that field is "[object Object]". It looks like CMSImport is parsing it into an object and then doing ToString() on it! I can't see any way to tell CMSImport that a string really is just a string and should be left alone? I'd have hoped that when importing the data into a Textbox CMSImport wouldn't attempt to manipulate it in any way?
In case it's at all relevant, the data is being imported from an Excel file (it's exported using your MemberExport package).
Incidentally - there's also a bug in the Excel import. If the Excel file contains no sheet named "sheet1" you get an error and can't proceed (even though it then lets you select which sheet to import data from). MemberExport creates a spreadsheet with a single sheet named (IIRC) MemberExport, so it's necessary to open it in Excel and rename the sheet before it can be imported.
The excel is after you modified a sheet? That is a nasty one and will be fixed.
CMSImport is always converting to the type of field in the database and an object is used to get it from the reader.
No, I only edited the exported data to change the sheet name so I could import it - I was trying to use it directly from MemberExport.
How do I import JSON data then? It's just a string, as far as Umbraco is concerned, but CMSImport is obviously recognising it as parseable into an object and doing that, but then just using ToString() to render it back to a string for Textbox. Surely when importing to a text field it should leave the content it receives alone and not attempt to turn it into an object?
Umbraco bug. There are some clumsy workarounds, including prefixing the JSON string with something so it doesn't look like JSON, then removing that prefix when you need the data.
Thanks for posting the workaround, maybe you can add that to your sheet Geoff?
Thanks Nicholas - that's very useful!
That would have caused problems sooner or later anyway in this case, regardless of CMSImport (I'd changed the field to Textbox as it was set to ContentPicker, but the the data format had been made more complex and was no longer actually compatible with ContentPicker - when CMSImport imported it it tried to transform it into ContentPicker data which, not surprisingly, didn't work. I'd hoped Textbox would mean it would just be left as a text string! I suspect it would still have saved okay from the custom code that uses it, as that wasn't objecting to the conflict with ContentPicker, but if the member was edited in the back office it likely wouldn't have gone so well in either case!
Richard - yes, in this case I can work around the issue by prefixing the values as Nicholas suggests, and stripping them in the calling code.
I can confirm that adding a prefix ("-" in my case) to the JSON data in the spreadsheet results in it being imported unmolested.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted