Friday, February 3, 2017

Sitecore adding a style sheet to a custom experience profile tab

After creating a custom contact facet (data store) and having this display in the experience profile for each user, you may be left wondering why it doesn't look quite as good as the other default tabs.

A custom tab
The default details tab 
The details tab shown above has both JavaScript and CSS which controls it's behavior, both of these files are located in: Website\sitecore\shell\client\Applications\ExperienceProfile\Contact\Details. You will have already created the JavaScript file to populate the data onto your custom tab, the next step is creating the CSS and registering it onto the page.

To add custom CSS to the experience profile

  1. You will need to download a copy of Sitecore Rocks - I use the standalone version.
  2. Connect Sitecore Rocks to your Sitecore instance.
  3. Find the Page Settings for the Experience Profile: /sitecore/client/Applications/ExperienceProfile/Contact/PageSettings.


  4. Add a new item of Page-Stylesheet-File template.



  5. Set the Stylesheet field on the new item to the physical path of your CSS file.


  6. Reload the Experience Profile and your custom style should be applied.
It's also worth noting that the DetailsTab.css file (located in: Website\sitecore\shell\client\Applications\ExperienceProfile\Contact\Details) provides an example of how to target the elements in the experience profile and provides a good base to work off.

Wednesday, February 1, 2017

Sitecore custom contact facet error on Experience Profile

After successfully implementing a custom contact facet inside Sitecore, the next step was then to display this data on a custom tab inside the Experience Profile.

Once all of the required steps were completed, the following error was appearing on the page and no data was displaying:
No pipeline was found for View [name]

This traces back to the configuration file where the data access layer (query, population, etc.) is registered.


In the example above, the XML element is titled "employee". Which then means that the JavaScript file which is adding the new custom tab should reference it inside the base URL for the service.
var baseUrl = "/sitecore/api/ao/v1/contacts/" + contactId + "/intel/employee";
Ensuring these two variables matched, stopped the error from occurring.

Sitecore Rocks SSL error

When attempting to use Sitecore Rocks on a local Sitecore instance that is set to use a secure connection, the following error was appearing when testing the connection.
Could not establish trust relationship for the SSL/TLS secure channel with authority 'host name'.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

The remote certificate is invalid according to the validation procedure.


In my case I was using the IIS Express Development Certificate which comes by default with the IIS install. The first thing to check is to ensure that you are using the host name which corresponds with the certificate you are using. In this case the host name localhost is expected.


I was using another host name which is what was causing this error, by changing the host to localhost it worked as expected.

If this doesn't work for you then it may be that the certificate is not trusted. The following article will provide details for trusting your certificate.

Sitecore viewing and querying MongoDB

When working with Sitecore it can beneficial to be able to view the contents of MongoDB. This comes in handy for tasks such as ensuring a user is added to a contact list or perhaps your custom facets are populating with data as expected.

This will require Robomongo, which put simply is graphical management tool for MongoDB. The main feature of this tool that is relevant to this blog post, is the ability to view and query the data. It does a whole lot more, but one interesting feature worth mentioning is that "First MongoDB tool with fully asynchronous, non-blocking UI".

After installing Robomongo, you can then give it a connection to your local MongoDB instance. This is likely to be via the connection string: localhost:27017. Once it loads up you will see all of the available databases in the left pane.


Expand the analytics database for the instance of Sitecore that you are working on. In this case I am working with the contacts, so will be querying on this.


You are now given an empty query that shows all of the contacts for your Sitecore instance.


If I wanted to find a user with a specific email address, the query would be:
db.getCollection('Contacts').find({"Emails.Entries.Preferred.SmtpAddress":"1@email.com"})


You will notice that the query is a dot notation of the strucuture of the MongoDB object and in this case is looking for a string match.


However sometimes, you might want a more dynamic query. Such as all users who have an email address added. The query for this one would be:
db.getCollection('Contacts').find({"Emails.Entries.Preferred.SmtpAddress":{$ne:null}})

These are just a couple of quick examples of how to view and query the contents of your Sitecore MongoDB.

Monday, January 23, 2017

Sitecore WFFM viewstate validation error

A fresh install of web forms for marketers had been deployed to a scaled 7.5 instance of Sitecore. The following error message was reported by a user:
Validation of the viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same ValidationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Looking into the web.config files the machineKey element was completely missing. The Sitecore scaling guide had the following to say:
In a single instance environment, you shouldn’t change the configuration.

If the environment contains two or more instances:

In the web.config file, set the validationKey and the decryptionKey attributes of the /configuration/system.web/machineKey element to a non-auto generated value. Ensure that the values are identical for all the instances within the environment and that the IsolateApps modifier is not present in either value.
Therefore a machine key generator can be used to generate a valid machine key. An example would be:
<machineKey validationKey='7652D32FB7D858DC44FA409A88FDB9AC8E9811C4F2F4174F138A7901F53CF8E759551BA8EBCD923B5FFEE87737BDA8DA18337BDE51E7C89934B4B1D4F3C84F01' decryptionKey='8158C85A02EADC24CDD400E2E71D2D77B6B3A14E4EABD041'   validation='SHA1'/>
Take note that IsolateApps is not present after either of the keys and that a key is set rather than AutoGenerate.