Lightning Conductor Calculated Columns Part 2
This is the second in a multi-part blog post on creating calculated columns within the Lightning Conductor Add-In for SharePoint Online. You can find the first post on the Lightning Conductor Calculated Columns here: https://lightningtools.com/blog/lightning-conductor-calculated-columns-part-1/
Within this post, we learn how to work with the Lightning Conductor to refine the results of the Content Type Managed Property using a Calculated Column.
When using the Search Rollup Engine Provider to aggregate results, you might find that the ‘ContentType’ column contains extra information that you perhaps wouldn’t normally see. As you can see from the image below, the ‘ContentType’ column is displaying the following information ‘application/vnd.openxmlformats-officedocument.wordproessingml.document My Custom Content Type’. This is not information you’re going to want to see as a user. The only information we would want to see is the ‘My Custom Content Type’
This can be an issue to some administrators as they perhaps do not want their users to see this information.
We can simply use a ‘Calculated Column’ to return the actual content type in SharePoint.
We first need to add the ‘ContentType’ managed property to the Lightning Conductor Add-in
This allows you to access the ‘ContentType’ column in the Search Rollup Engine Provider.
To do this we simply need to type in the following in the ‘Managed Property’ field located in the Lightning Conductor Add-in in the columns tab: ContentType
Make sure you add it as a ‘Text’ type column.
To create a ‘Calculated Column’ you need to perform the following steps given below
1. Select the ‘Actions’ menu on the ‘Lightning Conductor App Page’. And then select ’Configure View’. (This section is presuming you have already selected the ‘Search Rollup Engine Provider’ and configured your ‘Data Source’)
2. Locate your way to the ‘Columns’ tab in the Lightning Conductor Configuration and select ‘Add calculated column’
3. In this section we will want to give the column a ‘Column Name’ and type the formula required. You will need to use the following formula, and specify it as a ‘String’ column type:
[ContentType].substr([ContentType].indexOf(‘\n’)+1)
This formula located the position (IndexOf) of a newline character (\n) within the ContentType value, moves to the next character (+1), and then returns all characters after that, using the substr function.
As you can see from the screenshot below, the ‘Calculated Column’ works successfully as it’s removed the ‘application/vnd.openxmlformats-officedocument.wordproessingml.document’ ‘from the managed property ‘ContentType’ column results.
<Carl/>