Most Recent

View and download Sitecore log files using Log Viewer

As a Sitecore developer you would want to regularly monitor the log files for recurring errors and warnings and keep them clean. I am quite used to downloading my log files and running the tools like Sitecore Log Analyzer to filter and group errors and warnings.  As we started to productionise our website and apply the security hardening best practices, I ended up losing access to the logs folder and admin pages. To complicate the things further we started using containers to host our Sitecore instance with zero access to file system for developers, even when it is needed for troubleshooting issues.  The only way I could access the logs was using AWS Log Insights which gives you a stream of events without any option to download the full log file. It is especially difficult to troubleshoot issues when you need to correlate events from multiple logs which means you need to look for events across multiple log streams and try to put together the jigsaw puzzle to see the full picture. This

Running SQL Queries On Sitecore Databases Using Sitecore PowerShell Extensions

  Whether you are developing on Sitecore or supporting a live Sitecore instance, there are times you need to access the SQL databases to run queries to fetch some data. While the Sitecore APIs provide access to the items in the content tree, they are not very useful when you want to check the old login tickets in core database, or need to inspect the JWT tokens received from identity provider when using federated authentication.  There are many reasons for a Sitecore developer to want to access the Sitecore database. I am sure there are equal if not more number of reasons for the security team to deny access. Many a times you would be an admin on the Sitecore instance but won't even have read-only access to the SQL databases. In this article I am going to show how you can run simple queries on the Sitecore databases using the power of SPE. For this to work, you need to have access to use the PowerShell ISE on the Sitecore instance. First, we will need to fetch the connection string

Sitecore OData Item Api extensions for reference type fields

 Sitecore OData Item Api provides readonly access to Sitecore items. The OData Item Api is particularly useful when you need to pull some data from Sitecore to show on a non-Sitecore websites. In my case, I needed to pull a list of current job opening in my organization to show them on our company's non-Sitecore website's careers page. For more information on OData Item Api and how to query the data, check the Sitecore documentation page . One thing that particularly bothered me when using OData Item Api service to get an item and its field values using a query like below is, the lack of support for getting the link field target URL in one query. /sitecore/api/ssc/aggregate/content/Items('{F7SDEBB9-6AB1-4ACC-A790-FE627DD18722}')?$expand=FieldValues&sc_apikey={ADGT918E-8F0F-4F7E-8C77-DEE3F4F2E1Y1} When you run the above query against an item with General link field, the output for the field values looks something like this As you can see, the link field value is just

Data source and children content resolver

If you worked on a Sitecore JSS implementation you must be familiar with the Rendering Content Resolvers used by the Layout Service to serialize the contents of a rendering data source into JSON. Out of the box, Sitecore comes with the following Rendering Content Resolvers Datasource Resolver    The default resolver which serializes the data source item Datasource Item Children Resolver   Serializes the datasource item's children Context Item Resolver Serializes the context item instead of the data source item Context Item Children Resolver  Similar to Datasource Item Children Resolver but serializes the children of the context item Folder Filter Resolver Serializes not just direct children but also the descendants of the data source item, excluding folders As you can see, there is no out of the box contents resolver that can serialize both the data source item and its children. This will be handy when you have a module that contains a parent data source item and children items cr

Referencing local data sources using ID instead of path

In my previous blog post  we discussed about the problem with renaming local data sources and the issue with converting data sources created in a hierarchical structure to IDs using the out of the box PowerShell script. In this post I am going to show how to prevent using path to reference local data sources in the first place. Sitecore decides on whether to use ID or path to link data source to the rendering in presentation details at the time of selection of data source using the Select Associated Content dialog. So, I decided to take a look into what's happening behind the scenes when you click OK on this dialog using the network traffic monitor in the browser developer tools. I noticed a call to the following URL with the below response. The response has a command called SetDialogValue with the path of local data source as value. The same call ha

Fix for the issue with renaming local data sources resulting in broken links

Sitecore introduced local/page data sources with SXA. The local data sources allow better organisation of your page specific and shared data sources. However, one challenge with local data sources is, the links to them won't automatically get updated when you rename them. This is because Sitecore uses the path instead of ID to link to local data sources. If you inspect the raw value of final renderings field of a page with module that has local data source you can see the path "local:/Data/...". For this reason Sitecore warns about renaming local data sources manually. The documentation clearly says you need to convert your local data source paths to IDs using the out of the box scripts provided before renaming the local data source item. (Source: The script works fine in most cases, except for when not all your data sources are direct children of

Using Sitecore FXM to update and track contacts

Sitecore Federated Experience Manager aka FXM is a great feature to utilize some of the Sitecore's CMS, marketing and analytics capabilities on non-Sitecore websites. If you are new to FXM you can read more about how to integrate FXM into your non-Sitecore website and utilize its capabilities on  Sitecore's FXM documentation page . While the well-known uses of FXM are to add placeholders to pages to show Sitecore content, track click action, assign marketing attributes and track goals, the area FXM lacks out of the box is contact tracking and updates. The FXM's scbeacon JavaScript API has following three methods you can use trackEvent trackGoal trackOutcome You can read more about these methods in the documentation . As you can see there is no out of the box API method to identify or update contact. In cases where you have a non-authenticated public website on Sitecore but an authenticated member portal on non-Sitecore website it would be really useful to pass the authentic