Skip to main content

Using the Source Property

For each of the properties in your template you can set a source for it, this isn’t always used but can improve user experience drastically when done throughout a site. The source field comes in to play whenever you are using any of the following fields: Droplink, Droplist, Droptree, File, Grouped Droplink, Grouped Droplist, Image, Multilist, Treelist, Rich text field and a number of others.

There are various ways of setting these up to achieve different results – but in general you are using the source to limit the set of items that can be used, and this requirement can also help you determine what kind of field to use. For example, if you have a Set of items all split down into sub folders and want the content editor to make use of the tree, you could use a TreeList or Drop Tree, but if you just want a set of items without the opportunity to see where those items are – multilists or droplinks are the way to go. For Images you’re generally just specifying where to look for and put the images within the media library, and for Rich text fields the source determines the type of editor to use (if not the default).

There are a number of options for setting the source property but not all can work with every field.

Setting the Root Node: To do this you just give the full path to the item you want to use as the ‘root’. This works with just about every field that pulls options and you can easily grab the path from the content pane when you select your desired item(looking at the Item Path). Ie: if you have a treelist and you only want to show the categories item and its children, you’d put in the path to that item: /sitecore/content/Data/Categories

Sitecore Query: This applies to a smaller set of fields (the List Fields), but gives a lot of power and is what I’ll mainly be going over. The fields you can use this with are: Checklist, Droplink, Droplist, Grouped Droplist, Grouped Droplink, or Multilist. You can also use the fast query: this has some limitations over just using sitecore query but gives benefits of better performance and using less memory.

Treelists are also a little special and can use parameters(I think some other fields will work with this as well, but I most often end up using the query on other items so I don’t have a ton of experience with this), you can specify the root item, what templates/items to display or ignore and which they can select, for example:


The above sets the root node to /Sitecore/Content/Home/Root/Node and allows the user to select items using desiredTemplate1 or desiredTemplate2, it also excludes secretFolder and secretItem from showing up in the list as well as allowing the user to choose more than one of the same item.

More on Sitecore Query

Using the query option over simply setting a root node improves the experience for your clients as well as helps to keep your data accurate. If you don’t want them to be able to pick a certain template or value or need to select something dependent on a specific axes – using sitecore query will make it possible.

In the source field, your queries need to begin with query: followed by your query. I’m going to go over a few examples I’ve found useful, but for a more detailed explanation of using Sitecore Query take a look at the Data Definition Reference, there is a Sitecore Query section that explains all the details!

So, a few useful tidbits:

* grabs all the children of a node: query:/sitecore/content/home/dessert/*  <--  the * grabs every child and / followed by text denotes the exact item name you’re looking at. So you could also mix this up a bit and return query:/sitecore/home/*/pie/* <-- this will grab all the items that have a parent pie from any item under home with the pie grandchild.

. references the context item, this can be handy if you need to find the ancestors, children or anything along the axes (if you need just the parent, use: .. ): query:./pies/* <-- if we were the dessert item, this would grab all the grandchildren with the parent pie.

// is the descendant axis – this should be used Very sparingly but can be done the following way: query:/sitecore/content/home//pie/* <-- this grabs all the items with a parent pie under home. So that would include, home/pie/*, home/anything/pie/* and so on. The fear with using this is that you’re going to return the whole tree or a whole section which might have thousands of items, so when considering using the descendant axis or any query, be mindful of the result set you will get.

@ denotes a field, and @@ denotes an xml attribute for the item, you’ll probably be using mainly @@templatename or @@templateid.

For example: query:/sitecore/content/home/dessert/*[@pastry=’1’] <-- this grabs all the items under desserts which have the checkbox ‘pastry’ checked (so it might return pies).

Sitecore query also supports the xpath axes, allowing you to use things like ancestor-or-self, following and preceeding (siblings) and so on:


For a more practical example in a multisite solution, the above takes the current item, finds an ancestor or itself that represents the top ‘site’ item and then find the Data folder and then grabs all the children of the Touts folder.

Logical operators can be used to combine options as well, so we could look for query:./*[@@templatename='template1' or @@templatename='template2'] or something more like query:./pies/*|./cakes/* <-- this would give both children of pies and cakes instead of choosing one or the other.

There are also functions you can use (here’s a link with a listing of a number of useful functions), primarily I end up using: position(), last(), and contains()

To use them, you’d do something like query:./*[position()=1] <-- grabs the first item

query:./*[position()=last()] <-- grabs the last item

query:./*[contains(@ingredients,’apple’)] <-- grabs the items with ‘apple’ in their ingredients field, this could also be written as: query:./*[@ingredients = '%apple%']

To test out any query, you can always open up the developer center and then open the xpath builder. You do not need query: before your query but you do need to include fast: if you want to use the fast query.

These queries can become pretty complex depending on your needs, but that initial work can leave content editors with a very easy to use and understand set of items and fields. Leave a comment if you know of any good query examples or are wondering how to form a query to meet your needs (I’ll try to help)!


  1. Hi, excellent post!

    I'm trying to do something that seems simple, but I haven't been able to figure it out.

    I have a "Magazine" template with "Article" children. I have a droplist field "Featured Article" in Magazine, where I only want to select from the child articles of that particular Magazine item.

    Does that make sense?


  2. Hey Dennis,

    Thank you for commenting! For the Droplist field source try: query:./*

    That will pull all the children of the current item (being the Magazine)- if you have more than articles as children, you can specify the template too: query:./*[@@templatename='Article']

    As long as the magazine doesn't have Too many articles, this is also an instance where you are probably Ok to also use the descendant axes: query:.//*[@@templatename='Article']

    I hope that helps!

  3. Ah, perfect. I knew it was simple. I just haven't used the query syntax much at all.


  4. I love the fact that you called and talked to me today to grill me on Sitecore and had I realized it was you, I would have told you how your blog here was instrumental in helping me on a few things on my last project. This very blog post of yours was a huge help in trying to work out syntax of some really complex query stuff I was doing on my last project .. not to mention a number of other posts on your blog. Thank you!

  5. Hi, is this possible to set source to get the parent item of selected item? I use Internal Link and seems that I have no luck using query. Thanks

  6. Awesome post Amy. This was the perfect answer to a complicated problem we were trying to solve today. Thanks for sharing!

  7. Really very nice post.
    I am using Sitecore V 6.4
    From Develope center below query
    query:ancestor-or-self::*[@@templatename='Site Home']//*[@@templatename='mytemplate']
    returns all the items with template 'mytemplate' under Site Home ( so far so good)
    but from Content Editor it returns only first item under the Site Home.
    Can you please guide me what i am doing wrong?

  8. It comprises of all the essential feature to create any complicated HTML document visually, like designing tables, inserting images, page backgrounds, editing text and paragraphs, and also spellchecker, Search/Replace Source editor.

  9. Hi,

    what is the difference between

    query:./*[@@templatename="Home Page"]


    query:./item[@@templatename="Home Page"] ?

    the second one does not work for me when I specify it in droplink source field.

    Thank you

  10. Hi,

    I have two folders - 'Countries' and 'Disclaimers' for my site.
    I have a template 'xyz' for a Country with two fields - ''Country Code' of type Single-Line Text and 'Disclaimer Type' of type Droplink; The source of 'Disclaimer Type' is the path of 'Disclaimers' folder specified as a query.

    Now I want to have the same two folders for all my sub-sites and want to use the same template 'xyz' so that it chooses the Disclaimer present in the respective Disclaimers folder of the sub site.

    I need help with the query in Droplink field so that the Disclaimers path can be specified dynamically based upon the sub-site I am in.

  11. This is the nice article on
    sitecore please keep Sharing
    For more updates Click here

  12. Using 8.2, I'm trying to get your // working but it doesn't seem to work either for image or file fields. I've tried numerous varients, such as:
    query:/sitecore/media library/Regions//Graphics/*
    /sitecore/media library/Regions//Graphics/*
    query:/sitecore/media library/Regions//Graphics
    /sitecore/media library/Regions//Graphics

    Most seem to work fine in the Xpath Builder, but then when added on my field and clicking either Open File or Browse on the item's field, I get an error of Value cannot be null. Paramter name: value. Also if I expand the fields out of the template in the tree view in the content editor, it shows a broken link icon next to the field in question with this. A more straightforward source like just /sitecore/media library/Regions/East/Graphics works fine, just not the descendent. :-(

  13. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    msbi online training

  14. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.

    ReactJS Online Training

  15. Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. 

    Tableau online training

  16. Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries. I want to say thanks for great sharing.
    Sql server dba online training

  17. This is an awesome post. Really very informative and creative contents. These concept is a good way to enhance the knowledge. I like it and help me to development very well. Thank you for this brief explanation and very nice information. Well, got a good knowledge.
    Selenium online training
    Selenium certification training
    Selenium online course
    Selenium training course

  18. its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    python training in chennai

    python online training in chennai

    python training in bangalore

    python training in hyderabad

    python online training

    python flask training

    python flask online training

    python training in coimbatore

  19. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...
    This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

  20. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...
    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

  21. Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    AWS certification course in Chennai

  22. Looking a more unique post from your article.Great Article, very useful information, thank you !!
    Reactjs Training in Chennai |
    Best Reactjs Training Institute in Chennai |
    Reactjs course in Chennai

  23. NordVPN Crack is a fast and robust VPN and defends our individual information on the system. Also, It opens all the forbidden sites. Cracked Nord VPN

  24. Microsoft Office 2010 Crack with Activation Key Free Download. Throughout the whole world, MS office has been regarded as a package MS Office 2010 Activator Key

  25. Happy birthday messages to my best friend is for that true friend amidst that large company of friends whom we enjoy to share time, events, and experiences Fighting Sister Birthday Quotes


Post a Comment

Popular posts from this blog

Web Forms for Marketers: Send Email

To have the save action for your form actually send email, you will need to change one of the settings, otherwise you will receive this error whenever submitting the form: We experience a technical difficulty while processing your request. Your data may not have been correctly saved. Also in your log (/data/logs/newest log file) you will see this error after the form has been submitted: Exception: System.Net.WebException Message: The remote name could not be resolved: '' Source: System at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralA

Adding your own Icons

I have returned from blogger oblivion – stay tuned for more frequent updates! I’m looking forward to meeting people at Dreamcore this year – I’ll  be sure to update as that is happening. Back to the topic: adding your own icons! As you may have noticed, items can be configured to have an icon – and Sitecore provides an extensive list of them. But you may want to add your own for whatever reason. To do this you’ll need an image suitable for making into an icon, and the ability to resize this image to the correct sizes (, Photoshop, GIMP). For our example we’re making an Arke Icon and we're going to say our largest icon will be 128x128, so we have a transparent png called logo.png to work with:  The image you want to use should have a transparent background unless you want the icon to be a square, and ideally not overly detailed as it will be very small. Next, we need to make this image into various sizes, and put logo.png into the appropriately named directories, the st