3

I am using a Custom Field Type called QueryableTreelist which is extended from built-in Treelist field type. When an item is added to this queryabletreelist field, the linked item do not show the link in Sitecore -> Navigate-> Links in the Sitecore Ribbon. I have rebuilt the link databases many times. I have added the Custom Field Type in the FieldTypes.config file via patching. And it is showing up in Showconfig.aspx also.

I have also noticed that if I use the built-in FieldType TreeList, then it works fine and updates the Link database.

The code for the QueryableTreelist is as follows:

public class QueryableTreeList : TreeList
{
    public new string Source
    {
        get
        {
            return base.Source;
        }

        set
        {
            if (!value.StartsWith("query:"))
            {
                base.Source = value;
            }

            else
            {
                string valueNoParameters = value;
                string parameters = string.Empty;
                if (valueNoParameters.Contains("&"))
                {
                    valueNoParameters = value.Remove(value.IndexOf("&", System.StringComparison.Ordinal));
                    parameters = value.Substring(value.IndexOf("&", System.StringComparison.Ordinal));
                }
                
                Item item = Sitecore.Context.ContentDatabase.Items[this.ItemID];

                if (item != null)
                {

                    try
                    {
                        Item itemQueried = item.Axes.SelectSingleItem(valueNoParameters.Substring("query:".Length));
                        if (itemQueried != null)
                        {
                            base.Source = "datasource=" + itemQueried.Paths.FullPath + parameters;
                        }
                        else
                        {
                            base.Source = string.Empty;
                        }
                    }
                    catch (Exception e)
                    {
                        Sitecore.Diagnostics.Log.Warn("QueryableTreeList.cs failed to run source query", e, this);
                        base.Source = string.Empty;
                    }
                    
                }
            }
        }
    }
}

I am using Sitecore 8.2 Update 2.

Thanks

2 Answers 2

1

We had a very similar scenario with a custom image field inheriting from Sitecore Image field. Tried all of the above, without any success whatsoever getting the references added to link database.

The way we solved it was to use the namespace for the field we inherit from when registering the field type within <fieldTypes>:

<fieldType name="Our Custom Image" type="Sitecore.Data.Fields.ImageField,Sitecore.Kernel" />

All of our custom overrides and UI changes for our custom image still function when working within content and experience editor, so I'm guessing that the field registration in node fieldTypes relates only to link database.

[Update] Upon further inspection, I now realize what we had wrong in the first place. We confused the field control (Image) for the field type (ImageField) and tried to register the namespace for the field control in fieldType.

Hope this helps.

Cheers, Christopher

3

You need to register your custom field in ~/App_Config/FieldTypes.config. Once done, rebuild the Link Database.

From this point on, the field references will get updated automatically when the item updates.

3
  • Hi @Mark, I have mentioned that in the description above that I have already done that but it is not working. Commented Jul 3, 2020 at 12:19
  • Did you map the field control to the field type in core?
    – Mark Cassidy
    Commented Jul 3, 2020 at 13:02
  • Hi @Mark, Do you mean /sitecore/system/Field types/List Types/QueryableTreelist in core database? If yes, I already have it. I guess this is mandatory to have. Commented Jul 3, 2020 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.