0

I have a simple list with a column of type 'Hyperlink or Picture' named 'TestHyperlink'. I've created a Managed Property at the Search Service Application screen for this column so it can be used later inside a Search Template. I do an index reset and fully crawl to make sure the system is aware of my newly created property.

Inside the Search Template I add the property to the ManagedPropertyMapping tag and create the following line:

console.log(ctx.CurrentItem.TestHyperlink)

The log shows me the url but not the description. I've read on the Internet it should return a csv value like this: 'url, description' but not in SP2016.

So my question in short; how can i get the description out of a 'Hyperlink or Picture' column in SP2016?

2
  • You don't need to do the index reset. I'll do a test and look for an answer for you. Commented Feb 6, 2017 at 11:26
  • That would be very nice of you. Thanks in advance!
    – JonasVH
    Commented Feb 6, 2017 at 14:19

5 Answers 5

0

Try:

console.log(ctx.CurrentItem["TestHyperlink.desc"]);

or also, maybe:

console.log(ctx.CurrentItem.TestHyperlink.desc);
3
  • Thanks for your reply but it doesn't seem to work as 'ctx.CurrentItem.TestHyperlink' isn't an object but just a plain string. Therefore it just return 'undefined'. Maybe I'm choosing the wrong Type format while creating the Managed Property?
    – JonasVH
    Commented Feb 6, 2017 at 8:56
  • What about console.log(ctx.CurrentItem["TestHyperlink.desc"]);?
    – Evariste
    Commented Feb 6, 2017 at 9:23
  • Nope same thing 'undefined'.
    – JonasVH
    Commented Feb 6, 2017 at 9:45
0

While waiting for a concrete answer I've used the following work around. I've split column 'TestHyperlink' into two other columns named 'TestHyperlink_Url' and 'TestHyperlink_Desc' formatted as type 'Text'. Afterwards I've created a Managed Property for mapping the new columns. As they are simple text columns it's now possible to use them in my Search Display Template.

0

Doing my own testing the Managed Property associated with the URL field only stores the URL and throws away the Description. In fact, if I search for the description I don't find it, but if I search for the URL I find that. So that means that during content processing it appears that the URL is the only part that is kept.

2
  • Thanks for your input @matthew-mcdermott Guess my workaround is the solution for my problem.
    – JonasVH
    Commented Feb 10, 2017 at 12:34
  • I would agree, particularly if you want the description searchable. Commented Feb 11, 2017 at 12:54
0

You should map your Managed Property to Crawled property ows_q_URLH_TestHyperlink.

Then your managed property will contain URL and description in format: "Url, Desc".

Then, in display template you can add some js to extract this url\description:

var UrlFull = ctx.CurrentItem.YourManagedProperty;
var UrlPath = (UrlFull .split(','))[0];
var UrlDesc = (UrlFull .split(','))[1];

to build hyperlink for example:

<div>Link: <a href="_#= $htmlEncode(UrlPath) =#_"> _#= UrlDesc =#_ </a></div>
0

You solution means that a need für every list und every link column to make a managed property und to make a special JS File for the libary to get the decription of the linkcolumn and the URL opened in a new tab.

my conclusio : it is not possible to get a generic soltion which renders all link typ column in a libary where it is connected als JS Link. :-(

But thank so much for bringing clarity in my mind !

best greetings chris

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.