Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chuck Kirklen 36 posts 184 karma points
    Nov 20, 2017 @ 22:48
    Chuck Kirklen
    0

    Error when importing dropdown values with single quote (apostrophe)

    Richard, When importing records from an Excel spreadsheet, all fields are coming across fine except for dropdown values containing single quotes.

    e.g., in the pilgrimsBrand field, which is a custom datatype based on Umbraco.Dropdown, a product with brand "GoldKist Chicken" imports properly and CMSImport creates the preval for the brand in the custom data type, but a product with brand "Pilgrim's Chicken" (note the apostrophe) fails to create the preval and the record is not created.

    Log shows: 2017-11-20 16:21:29,336 [P24188/D11/T96] ERROR CMSImportLibrary.Providers.ImportProviders.Content.ContentImportProvider - CMSImport:A record failed to import for aliaspilgrimsBrand System.Xml.XPath.XPathException: '//preValue[text()='Pilgrim's Non-Branded']' has an invalid token.

    It will import fine if I remove the apostrophe, and it will also import if i replace the single quote with either ’ or ', but the import creates prevals for "Pilgrim’s Chicken" and "Pilgrim's Chicken" instead of creating a "Pilgrim's Chicken" preval.

    I know that SQL doesn't like single quotes, and i've tried using a double tick (''), an escape tick (\'), and the ASCII equivalents, but can't seem to get it to work.

    Is there another trick or configuration setting to allow the import of dropdown values that contain a single quote?

    Thanks in advance!

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Nov 21, 2017 @ 07:04
    Richard Soeteman
    0

    Hi Chuck,

    It looks like the xpath expression is throwing the error . have you tried \' to escape the character?

    Hope this helps,

    Richard

  • Chuck Kirklen 36 posts 184 karma points
    Nov 28, 2017 @ 03:28
    Chuck Kirklen
    0

    Richard, That still generates an error:

    Error while importing data for property 'pilgrimsBrand', datasource record Sku # = '982', Error :'//preValue[text()='Pilgrim\'s Pride Brand']' has an invalid token.

    The preValue is "Pilgrim's Pride Brand" and in the Excel source, i have tried leaving the single tick character, escaping it as per your suggestion, and neither worked.

    The only workaround (and it's not a good one for the content editors who import data) is to change the single tick to a character (such as !), import, then go into the data type and change the preval from ! to ' so it appears correctly in the dropdowns to the editors.

    Is there another way to populate prevalues from the import when the prevalues contain a single tick?

    Thanks, Chuck

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Nov 28, 2017 @ 07:18
    Richard Soeteman
    0

    HI Chuck,

    The error is coming from Umbraco itself I am afraid. But since you can control both datatype values and import values can't you change to &quot that is the value that xml understand and doesn't throw an exception on.

    Hope this helps,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft