Copied to clipboard

Flag this post as spam?

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


  • Neil Chapman 17 posts 119 karma points
    Jan 30, 2020 @ 17:23
    Neil Chapman
    0

    CheckboxValueParser example not working

    Hi

    I have downloaded and installed MemberExport v3.8.1 via nuget and it works great.

    I'm following the example in the user manual to create a CheckboxValueParser but am receiving the error:

    'MemberField' does not contain a definition for 'GetPrevalues' and no accessible extension method 'GetPrevalues' accepting a first argument of type 'MemberField' could be found (are you missing a using directive or an assembly reference?)
    

    I have copied the code verbatim but updated the DataType GUID (should there be two attributes for 'PropertyEditorAlias'?):

    using MemberExport.Library.Types;
    using MemberExport.Library.ValueParsers;
    using System.Text;
    
    namespace Application.Core.Member.ValueParser
    {
        [ValueParser(PropertyEditorAlias = "fbaf13a8-4036-41f2-93a3-974f678c312a")]
        [ValueParser(PropertyEditorAlias = "Umbraco.CheckBoxList")]
        public class CheckboxValueParser : IValueParser
        {
            public virtual object Parse(object value)
            {
                return null;
            }
    
            public virtual object Parse(MemberField memberField, object value, FieldParserOptions fieldParserOptions)
            {
                if (value != null)
                {
                    var sb = new StringBuilder();
                    foreach (string item in value.ToString().Split(','))
                    {
                        var prevalue = memberField.GetPrevalues().FindLast(p => p.Id.ToString() == item);
                        if (prevalue != null)
                        {
                            if (sb.Length > 0)
                            {
                                sb.Append(',');
                            }
                            sb.Append(prevalue.Value);
                        }
                    }
                    value = sb.ToString();
                }
                return value;
            }
        }
    }
    

    I've added a reference to MemberExport.Library. Am I missing another reference?

    Thanks for your help.

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Jan 31, 2020 @ 08:00
    Richard Soeteman
    0

    Hi Neil,

    I should have updated the sample. Items are stored as JSON these days. I think you can just use value.ToString().Split(',')

    Hope this helps.

    Richard

  • Neil Chapman 17 posts 119 karma points
    Jan 31, 2020 @ 10:38
    Neil Chapman
    0

    I should have debugged the value...

    Having done so, I can see that the value always returns empty: enter image description here enter image description here Even though the value is being recorded in the database correctly: enter image description here

    Any idea why the value would always be empty???

    Thanks

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Jan 31, 2020 @ 10:49
    Richard Soeteman
    0

    Weird,

    Can only think that it returns infor from wrong column. What is the result of the following query? That is when Memberexport determines which column to use.

    select dbType from umbracoDataType where nodeId = 126

    About to go offline until Tuesday so sorry for any delays in reply.

    Best,

    Richard

  • Neil Chapman 17 posts 119 karma points
    Jan 31, 2020 @ 10:51
    Neil Chapman
    0

    There is no result!enter image description here

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Jan 31, 2020 @ 10:54
    Richard Soeteman
    0

    Sorry must been the other id 1373

  • Neil Chapman 17 posts 119 karma points
    Jan 31, 2020 @ 10:54
    Neil Chapman
    0

    Updated with the DatatypeNodeId (1373):

    enter image description here

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Jan 31, 2020 @ 10:56
    Richard Soeteman
    0

    That looks ok, No idea why it didn't retrieve the data then. Will come back to this next week.

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Feb 04, 2020 @ 10:20
    Richard Soeteman
    100

    Hi,

    This was due to a bug in the Core of memberexport where the checkboxlist items got parsed but not the JSON value. That is fixed in release below. You don't need a custom provider for this anymore.

    https://www.dropbox.com/s/j7xwa2njen3v41u/memberexport38_2.zip?dl=0

    Hope this helps,

    Richard

  • Neil Chapman 17 posts 119 karma points
    Feb 04, 2020 @ 10:25
    Neil Chapman
    0

    Hi Richard,

    Thanks for looking into this and getting back to me.

    I'll try out the release later today and let you know how it goes! Great that I won't need a custom provider :-)

    Thanks

  • Neil Chapman 17 posts 119 karma points
    Feb 05, 2020 @ 16:30
    Neil Chapman
    0

    Hi Richard,

    I downloaded and installed the package and removed my custom provider. The values are now being output but it doesn't look like the csv values are being quoted correctly.

    enter image description here enter image description here enter image description here

    I would be expecting the raw txt file to look like this:

    Id,How can we contact you
    1360,"Phone,Email,App notification,Pigeon,Post"
    

    Hope that helps.

    Will you be releasing this as an update to the Nuget package?

  • Neil Chapman 17 posts 119 karma points
    Feb 05, 2020 @ 16:34
    Neil Chapman
    0

    Ignore all that Richard!

    I had forgotten to select the Text Indicator field!

    Will you be releasing this as an update to the Nuget package?

    Thanks for a great product!

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Feb 06, 2020 @ 07:37
    Richard Soeteman
    0

    Great and yes but need to test the whole update first.

Please Sign in or register to post replies

Write your reply to:

Draft