Data Sources
Scripted Data Sources provide a way to use a PowerShell script to perform complex queries.
Here are some good reasons to use this feature:
Delivering complex functionality based on multiple criteria.
Your field may need to provide different set of items to choose from based on:
user name or role (in simplest case this can be done using right management, but maybe not always possible in a more elaborate scenario)
current day or month?
In a multisite/multimarket scenario you may want to show different items for each site
based on engagement analytics parameters of the page
based on where in the tree an item exist (some of it can be done with use of a “query:”)
anything you might want to build the code data source for…
Something that would be beyond the reach of a regular Sitecore query and potentially something that you would really need to deliver code source for. But maybe you’re not in a position to deploy that on your environment?
Field Data Source
Field Data Source provides a great opportunity for a script.
Below are field types you may wish to use a script:
Checklist
Droplist
Grouped Droplink
Grouped Droplist
Multilist
Name Lookup Value List
Droplink
Begin by adding a new script library called Data Sources followed by adding a script. You can call it something like Get-GlobalOption.
Add the path to your script in the Source field on the data template. The source should be prefixed with
script:
followed by the path.Enjoy the results.
Rendering Data Source Roots
//TODO
Rendering Data Source Items
//TODO
References
Sitecore Spark article on using scripted datasources
Last updated