0

I am using a Search Results with Refiner web part with SharePoint Online.

The search works, but it returns the URL of the list item, and when clicked on, the user is directed to the list item and all of it's fields. The user is able to look through those fields in the list item and then click on "Tool_URL", but I would rather have the "href" below to go directly to the value of the list field "Tool_URL" from within that list instead of the list itself, thus removing the need for the user to click twice.

Here is the code I have in my template.

<div class="template_root">
    {{#if showResultsCount}}
        <div class="template_resultCount">
            <label class="ms-fontWeight-semibold">{{getCountMessage totalRows keywords}}</label>
        </div>
    {{/if}}
    <ul class="ms-List template_defaultList">
        {{#each items as |item|}}
            <li class="ms-ListItem ms-ListItem--image" tabindex="0">
            </div>-->
            <span class="ms-ListItem-primaryText"><a href="{{getUrl item}}">{{Title}}</a></span>
            <span class="ms-ListItem-secondaryText">{{getSummary HitHighlightedSummary}}</span>
            <div class="ms-ListItem-selectionTarget"></div>
            </li>
        {{/each}}
    </ul>
</div>

I have searched to the best of my ability and I am coming up blank. Is it possible to modify the template to replace <a href="{{getUrl item}}">{{Title}}</a> with the value of the "Tool_URL" field from within the list item that it is pulling?

1 Answer 1

0

Sure.

You will just need to map the crawled property ows_Tool_Url to a managed property and add that managed property to the managed property listing in the top of you item display template.

Then extract the value of the that property (just to make it easier to inspect) and then replace the {getUrl item} with that value).

2
  • Thank you, this points me in the right direction. In my company we have a handful of people with the access to do this, unfortunately I am not one of these few, although I am a SharePoint developer ... I will work with these folks to get the managed property added so I can do what I am tasked to do. Thanks again! Commented Mar 6, 2019 at 16:47
  • FYI if you have a MSDN you can get your own dev tenant for free and test out that kind of stuff yourself Commented Mar 6, 2019 at 18:00

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.