Copied to clipboard

Flag this post as spam?

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


  • Profiterole 232 posts 264 karma points
    Oct 04, 2011 @ 23:47
    Profiterole
    0

    Import Value or Text

    Hi, I have a dropdown datatype and, in version 1.2, I had to put the value in my csv to map the datatype. Now, in 2.0, it seems that it does not understand value. Do I have to use text instead in my csv?

  • Profiterole 232 posts 264 karma points
    Oct 05, 2011 @ 01:36
    Profiterole
    0

    Ok, I figured it out. Now, I have to use the text instead of the value from my dropdown.

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Oct 05, 2011 @ 08:36
    Richard Soeteman
    0

    Hi Great that you already figured it out, indeed you need the text but that should also have been the case in 1.2

    Cheers,

    Richard

  • Tony Kiernan 278 posts 341 karma points
    Jun 18, 2012 @ 19:18
    Tony Kiernan
    0

    I am having difficulty getting cmsImport to match the text in a property dropdown (ultimate picker based on nodes).  Can't see anything in the manual pertaining to this.  Should it be doable?

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Jun 19, 2012 @ 08:55
    Richard Soeteman
    0

    Hi Tony

    Think the ultimate picker isn't supported out of the box. It is doable using a FieldAdapter, might want to checkout the documentation or this blogpost for that. Basically it takes a value and converts it to the desired format for the ultimate picker,The main issue with pickers is that most of the times you want to import url's and map those against nodes. This is really diffcult because it's hard to find a relation between the imported content and the url.

    But what do you want to import, maybe I can help you with a solution.

    Best,

    Richard

  • Tony Kiernan 278 posts 341 karma points
    Jun 19, 2012 @ 10:48
    Tony Kiernan
    0

    I have a bunch of nodes representing some fields in the imported data.  One set are for, say, location:

    • UK
      • North
        • Manchester
        • Liverpool
      • South
    • France

    The field in the CSV may read France or Manchester etc.  I want to pick the relevant node.

    (In the meantime, I'll check out hte blog and the documentation again)

  • Tony Kiernan 278 posts 341 karma points
    Jun 19, 2012 @ 10:57
    Tony Kiernan
    0

    PS. It did cross my mind that the additional spacing (and hyphens) put in by the ultimate picker might bethe problem.  So I changes it to only show one level and still it didn't pick anything up

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Jun 19, 2012 @ 11:04
    Richard Soeteman
    0

    HI Tony,

    You should check out the database how it stores the info, Then create a FieldAdapter that converts your data to that format then all should work,

    Cheers,

    Richard

  • Tony Kiernan 278 posts 341 karma points
    Jun 19, 2012 @ 11:31
    Tony Kiernan
    0

    The example in your blogpost seems to be out of date, there is an issue with the namespace CMSImportLibrary.Interfaces

    Should I really need to cast a value from text to Nvarchar?

    Edit: the value is already being treated as NVarchar.  It is being stored in the database, but has no relation to the values in the picker dropdown

     

  • Richard Soeteman 4049 posts 12922 karma points MVP 2x
    Jun 19, 2012 @ 22:36
    Richard Soeteman
    0

    Hi Tony you are right, namespace is CMSImport.Extensions.FieldAdapter reference the CMSImport.Extensions project.

    Complete example below, no need to cast the value to varchar. Only thing is that you need to make sure that the value you return is in the exact same format as the picker it normally would store. I usually check the cmsPropertyData table in the database how things get stored,

    using System;
    using umbraco.cms.businesslogic.property;
    using CMSImport.Extensions.FieldAdapter;
    
    namespace CMSImportLibrary.FieldAdapters.DefaultFieldAdapters
    {
        /// <summary>
        /// 
        /// </summary>
        public class BooleanFieldAdapter : IFieldAdapter
        {
            #region IFieldAdapter Members
    
            /// <summary>
            /// Contains the GUID of the datatype we want to parse using this FieldAdapter
            /// </summary>
            /// <value></value>
            public Guid DataTypeId
            {
                get { return new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"); }
            }
    
            /// <summary>
            /// Parse the data
            /// </summary>
            /// <param name="value">The value to parse</param>
            /// <param name="fieldAdapterService">The field adapter service.</param>
            /// <returns></returns>
            public object Parse(object value, Property property, FieldAdapterOptions fieldAdapterService)
            {
                if (!(value.Equals("0") || value.Equals("1")))
                {
                    bool boolValue = false;
                    if (bool.TryParse(value.ToString(), out boolValue))
                    {
                        return boolValue ? 1 : 0;
                    }
                }
                return value;
            }
    
            #endregion
        }
    }

    Hope this helps,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft