Copied to clipboard

Flag this post as spam?

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


  • Martin Lingstuyl 202 posts 378 karma points
    Jul 07, 2014 @ 09:46
    Martin Lingstuyl
    0

    fieldadapter not working

    Hi Richard,

     

    I'm implementing a 2.5.2 version of cmsimport on umbraco 6.5.2

    I've added a custom datasource which returns an xml file.

    I've added a custom fieldadapter which is supposed to parse a date value which is not automatically recognised by cmsimport. Only: the fieldadapter doesn't get hit in debug mode. At least: the DataTypeId Guid is hit, but not the Parse function. It basically ignores it, and returns the same error that it does without the fieldadapter.

    Any ideas?

    Martin

  • Martin Lingstuyl 202 posts 378 karma points
    Jul 07, 2014 @ 10:46
    Martin Lingstuyl
    0

    It seems the events don't get hit either. Both the interfaces (ApplicationEventHandler and umbraco.BusinessLogic.ApplicationBase)

     

  • Richard Soeteman 3377 posts 9853 karma points MVP
    Jul 07, 2014 @ 10:49
    Richard Soeteman
    0

    Hi Marin,

    I assume the Umbraco version is incorrect? But FieldAdapter should work, better to use a FieldProvider by the way, one of the recent changes.

    But weird that your Adapter never gets hit, it should so can you share the code? If you are mapping against a native Umbraco Date field I would love to know which one I've missed in the advanced settings.

    Best,

    Richard

  • Martin Lingstuyl 202 posts 378 karma points
    Jul 07, 2014 @ 10:53
    Martin Lingstuyl
    0

    6.5.1 indeed :)

    I will try out the FieldProvider as well.

    Here is the code.

    namespace ImportService.CmsImport.FieldAdapters
    {
        public class Date : IFieldAdapter
        {
            public Guid DataTypeId
            {
                get { return new Guid("2740bb3b-13c7-477f-87b8-be6a3c7f3464"); }
            }

            public object Parse(object value, Property property, FieldAdapterOptions fieldAdapterOptions)
            {
                /*             
                 * If date value, first do a parse exact, otherwise the date is not recognised as date.
                 * this takes care of birthdate and memberdate
                 *
                 */
                if (property.PropertyType.DataTypeDefinition.Text == "Date Picker")
                {
                    DateTime parsedDate;
                    DateTime.TryParseExact(value.ToString(), "yyyyMMdd", CustomFunctions.SetCulture(), DateTimeStyles.None, out parsedDate);

                    value = parsedDate;
                }
                return value;
            }
        }
    }
  • Richard Soeteman 3377 posts 9853 karma points MVP
    Jul 07, 2014 @ 10:59
    Richard Soeteman
    0

    So if you put a breakpoint on the if statement it doesn't get hit? Weird it should be since all is public.

  • Martin Lingstuyl 202 posts 378 karma points
    Jul 07, 2014 @ 11:06
    Martin Lingstuyl
    0

    by the way: trying out the fieldprovider. Can you show me a sample? I can't open your page. It gives me a javascript error (waiting for script to execute)  http://www.richardsoeteman.net/CategoryView,category,CMSImport.aspx:152

     

    (I think I had the same experience some time ago and emailed you on it, by now I have a new pc, but the error continues in firefox and chrome)

     

  • Richard Soeteman 3377 posts 9853 karma points MVP
    Jul 07, 2014 @ 11:12
    Richard Soeteman
    0

    Yes blog needs to be updated, some video script is killing it try this one http://www.richardsoeteman.net/2013/12/05/FieldProvidersInCMSImport25.aspx

  • Martin Lingstuyl 202 posts 378 karma points
    Jul 07, 2014 @ 11:26
    Martin Lingstuyl
    0

    Ok, I got it working using the fieldprovider. Thanks!

    (the Example image was loaded at the absolute bottom of the page, I discovered it at last :)

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft