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:

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:

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