September 10, 2019

Sitecore Roles PaaS Solr Connectivity

By: Craig Taylor
September 10, 2019


Sitecore Roles PaaS Solr Connectivity

Here's a quick one for everyone.  I recently provisioned a full Sitecore XP 9.0.1 environment in Azure PaaS.  The only exception to this is a VM that is running Solr.  I was getting a lot of errors in Application Insights about xConnect not being able to connect to the Solr server.  I suspected that I was missing a hybrid connection somewhere, but wasn't sure which role was missing it.

I couldn't find a list from Sitecore's documentation of all the roles that need to access Solr.  I know that I could look for the "ContentSearch.Solr.ServiceBaseAddress" setting to find all references to my Solr server, so I downloaded all the config files from each Sitecore role and found the one I was missing (xConnect Search).  I added the hybrid connection to the Solr server to my xConnect Search App Service and was back to running with no exceptions again!

Note: The "ContentSearch.Solr.ServiceBaseAddress" setting was removed in Sitecore 9.0.2 and is now in the "solr.search" connection string.

For reference, here are the 5 roles that should be able to communicate with Solr:

  • Content Management
  • Content Delivery
  • Processing
  • Reporting
  • xConnect Search

April 12, 2019

Limit TreelistEx Selections to X Number of Items

By: Craig Taylor
April 12, 2019


Sitecore Item Limit

I recently had a requirement to limit the content author's ability to select items.  In this case, they were only allowed to select two items.  I love using "TreeListEx" and therefore selected that field type.  I knew that I could set validation on fields and went about looking for the built-in validator that would limit the number of selections. . . I didn't find it.

While I was surprised to not find this validator, I thought that surely, someone else smarter than me had mentioned it on the interwebs; I was not disappointed.  A quick search yielded a StackOverflow post about it that cited a blog post.  In summary, apply a Regex value to the "Validation" field of your field. (Add a helpful "ValidationText" message while you're at it.)

I dutifully copied and pasted the Regex expression into my field and was a little surprised to see an error message while testing the validator:

Sitecore Validation Error

Well, that didn't go as expected.  After a bit of Internet sleuthing on the error, I found that there might be a character (or "characters") in the string that needs to be escaped.  I simply changed "^({[^}]+}|?){0,2}$" to "^(\{[^}]+\}|\?){0,2}$" (included the escaping 'backslashes' before the curly brackets and question mark) and was on my way!


Sitecore Validation Working

Update: And of course as I'm finalizing the research for this post, I see that Ben *actually* did solve this and it can be seen in the screenshot he included, but the Regex text in his post didn't include the escape characters