Copied to clipboard

Flag this post as spam?

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


  • Matt Stevenson 2 posts 32 karma points
    Sep 11, 2013 @ 12:32
    Matt Stevenson
    0

    Custom prevalue source not appearing

    Hi,

    Just started using Umbraco & Contour (and c# .net!) so hopefully what I'm about to ask is a question with a simple resolution that's just a result of me not configuring something properly.

    We have Umbraco 6.1.5 setup with the most recent version of Contour added and we're trying to get a custom prevalue type provider setup and available in the list of prevalue sources.

    As far as I understand it, this should just be a case of creating a class that extends the Umbraco.Forms.Core.FieldPreValueSourceType and making sure that the class in question is built into a dll in the Umbraco project folder - is that correct?

    At the moment, no matter what we try we can't get the new custom provider to appear in the list alongside the standard ones (Get values from textfile, SQL Database etc.).

    If it's helpful the following is the code of the custom provider as it stands...

    __________________________

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Umbraco.Forms.Core;

    using Umbraco.Core.Logging;

     

    namespace FlightCentre.Provider.Prevalue

    {

        public class LDAPAttributeQuery : FieldPreValueSourceType

        {

            //[Setting("LDAPQuery", description = "Query to run against the LDAP data sources(s)", control = "Umbraco.Forms.Core.FieldSetting.TextField")]

            //public string LDAPQuery { get; set; }

     

            public LDAPAttributeQuery()

            {

                this.Id = new Guid("BRIGHT-LDAP-ATTRIBUTE-QUERY");

                this.Name = "LDAP Attribute Query";

                this.Description = "Input the query to pull values back from the LDAP source";

            }

     

     

     

            public override List<PreValue> GetPreValues(Field field)

            {

                List<PreValue> result = new List<PreValue>();

     

                try

                {

                    result.Add(BuildPreValue(1, "Test prevalue 1", 1, field));

                    result.Add(BuildPreValue(2, "Test prevalue 2", 3, field));

                    result.Add(BuildPreValue(3, "Test prevalue 3", 3, field));

                }

                catch (Exception ex)

                {

                    LogHelper.Error(this.GetType(), "Error: LDAPAttributeQuery provider: " + ex.ToString(), ex);

                }

     

                return result;

            }

     

     

     

            public override List<Exception> ValidateSettings()

            {

                List<Exception> exs = new List<Exception>();

     

              //  if (string.IsNullOrEmpty(LDAPQuery))

              //  {

              //      exs.Add(new Exception("LDAPQuery setting has not been provided"));

              //  }

                return exs;

            }

     

     

     

            private PreValue BuildPreValue(object id, string value, int sort, Field field)

            {

                PreValue pv = new PreValue();

                pv.Id = id;

                pv.Value = value;

                if (field != null)

                {

                    pv.Field = field.Id;

                }

                pv.SortOrder = sort;

                return pv;

            }

        }

    }

    ______________________

     

    As you can probably see, the class in question is eventually going to serve data from an LDAP data source but at the moment, we've just hardcoded some example prevalues into it.

    FYI, this class is located in a 'classes' folder within the web application project that is using Umbraco. We've used the object explorer to check that the class in question actually appears in the project dll file that is built into the bin folder and it does.

    But unfortunately the custom provider still does not appear - any help or suggestions greatfully received.

    Thanks,

    Matt

     

  • Comment author was deleted

    Sep 11, 2013 @ 14:38

    Not sure if this is valid

    this.Id = new Guid("BRIGHT-LDAP-ATTRIBUTE-QUERY");
    

    Try an actual Guid that might solve it http://www.guidgenerator.com/online-guid-generator.aspx

  • Matt Stevenson 2 posts 32 karma points
    Sep 11, 2013 @ 15:16
    Matt Stevenson
    0

    Hi Tim,

    Thanks for that, that sorted the problem (I had a feeling it was going to be something simple that I'd misunderstood!).

    Thanks again for the help,

    Matt

     

  • Comment author was deleted

    Sep 11, 2013 @ 15:50

    Sweet glad it's sorted and good luck with the prevalue source type ;)

Please Sign in or register to post replies

Write your reply to:

Draft