SharePoint 2013 and O365: Lookup column Value ID missing
-
06-10-2020 - |
Question
Okay, this is my first question so forgive me if this is long winded.
TLDR: I cannot seem to be able to target or get the Value ID of the Category Column in a blog post rollup. Why is this?
SharePoint Version/s: Office 365/SharePoint Online, SP 2013. Also have SharePoint Designer.
Background:
I'm still fairly new to xsl and usually just keep trying code until it works (or doesn't). I have created a new Item Style for a "Feature News Rollup" CQWP to display Blog Posts on my home page. It looks a little like this (where each item has a background image):
I am having some trouble with the Categories in the top left of the main blog post. The categories come from the default Post's Category lookup multi field. Through some searching I have changed the style from default Category1;Category2;Category4 to create end and start span tag for each.
What I need to do / Problem:
Now that that I have them separated, I need to get them to link to the page that has them filtered by Category ID. Url is:
https://{mysite}.com/{blogsite}/Lists/Categories/Category.aspx?CategoryId={ID}
where {ID} in this case in the Lookup Value ID. I have seen through my searches to separate each category that for SP 2007 and 2010 (at least) the Lookup value has "behind-the-scenes" code:
[LookupID];#[LookupValue]
BUT, I can not seem to target the [LookupID] at all. Every variation of concat, substring-before, and substring-after have no results and gives me the impression that in O365 (at least) and in SharePoint 2013, [LookupID] simply does not exist or cannot be targeted.
It seems to me that its "behind-the-scenes" code is:
;#[LookupValue]
Bonus code (separates each Category into own span):
I got the code for the template called MultiSelectDisplay from http://spxslt.codeplex.com/discussions/453868
<span class="FNewsCategory">
<xsl:call-template name="MultiSelectDisplay">
<xsl:with-param name="MultiSelectValue" select="@PostCategory" />
<xsl:with-param name="MultiSelectDelimiter" select="'; '" />
<xsl:with-param name="MultiSelectSeparator" select="'</span><span class="FNewsCategory">'" />
<xsl:with-param name="Link" select="''" />
</xsl:call-template>
Questions:
- Is it even possible to get the [LookupID] at all in SharePoint 2013 and O365?
- Is it possible to do this through xsl? If so, how do i do this?
- If it is not possible through xsl, how would you recommend I get the same results that this CQWP is providing me?
Solution
My Solution: Javascript
I've ended up using a javascript file to finish the job. In the ItemStyle.xsl I have used an edited version of the MultiSelectDisplay code above to give them start and end <div>
tags with a class (FNewsCategory). I have then created a javascript file (with help) to:
- Look for a containing the Category name (e.g. Special).
- Add a class (e.g. FNewsSpecial). This is so I could add a different background color based on different categories.
- Add a link to this particular category (needs to be hardcoded, full URL).
Before Javascript:
<div class="FNewsCategory">Special</div>
After Javascript:
<div class="FNewsCategory FNewsSpecial">
<a href=".../Lists/Categories/Category.aspx?CategoryId=5">Collaboration</a>
</div>
Ultimately this means that for every category I have, I need to make sure there is a corresponding link in the javascript file. That's not too bad because I don't plan on using all too many.
Unanswered Question: Is it even possible to get the [LookupID] at all in SharePoint 2013 and O365?
I still haven't found an answer to whether or not you can get the [LookupID], but I will keep searching.