#StackBounty: #sharepoint-online #jquery #html-form-web-part SPO filter results to display 'Title' field values while filtering…

Bounty: 50

I want my autocomplete filter to display the search results based on the Companies list item’s Title field while filtering the page’s WPs based on another field in the Companies list. I am working with the following lists (see image below). I cannot get this working — any help or guidance would be appreciated!

  • List view WP “Companies” [cols: ID, Title, CiqId]
  • Document Library view WP “SourcesLibrary” [cols: CompanyId, CiqId] (!)

(!) CompanyId is a text field populated by Companies list,’Title’ field
(!) CiqId is a text field populated by Companies list, ‘CiqId’ field

sample list/library data

The Filter
I have an HTML WP filter whose autosuggest results are populated by the “Companies” list ‘Title’ field. This is working properly. What I can’t figure out is how to use this filter to filter the page web parts based on the ‘CiqId’ field while still displaying the ‘Title’ field values as search results. I;ve included the script for this filter at the bottom of the post.

When the term “3M” is entered into the HTML Form WP filter, the value “3M” is displayed in the filter’s dropdown results while the list view and library WPs are filtered by the value “D”, as that is the value in the item’s ‘CiqId’ field. This results in the list view and library WPs showing all items and documents matching the ‘CiqId’ value “D”, which would include “3M” and “Post-it”.

Right now, my filter displays the Title field as search results and filters the page’s WPs based on that value as well.

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- css -->
<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.css" rel="stylesheet" >
<link href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css" rel="stylesheet" >
<link href="//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" >
<link href=//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" >
<!-- js -->
<div id="preloader" class="spinner"></div>
<script type="text/javascript">
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body> <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>Companies</listName><viewFields><ViewFields><FieldRef Name='Title'/> </ViewFields></viewFields> </GetListItems> </soapenv:Body> </soapenv:Envelope>";
    //Make a call to the List WebService using the SOAP envelope described above.
    //The URL is fixed to a Specific Site Root.  Feel free to change this
    //to your own fixed root or do some jscript voodoo to figure out where
    //Of course in 2010 you can do this with the Client Object Model, or hit
    //the list rest Service and return json, so enabling jsonp cross site calls.
        url: "https://birchbox.sharepoint.com/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv, 
contentType: "text/xml; charset="utf-8"",
success:  function( xmlResponse )         { 
var domElementArray=$( "z\:row", xmlResponse ); 
   var dataMap = domElementArray.map(function() 
   return { 
   value: $(this).attr('ows_Title') , 
   id: $(this).attr('ows_Title') 
            var data = dataMap.get(); 

            //Find the Sharepoint Portal Search Box (this is a poor selector, but it is not properly named by sharepoint, well it is but INamingContainer gets in the way)    
           $( "#tags2" ).autocomplete(    
            {                 source: data  



<div id="gobuttons2">
<div class="ui-widget"></div>
<div class="input-group mb-3" onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
<input id="tags2" name="tags2" input type="text" class="form-control" placeholder="Type a company name and click 🔍" aria-label="Type a company name and click 🔍" onchange="javascript:_SFSUBMIT_"/>
    <div class="input-group-append">
<button type="submit" class="btn btn-outline-danger btn-sm" onclick="javascript:_SFSUBMIT_"><i class="fa fa-search"></i></button>
<button type="button" class="btn btn-outline-dark btn-sm" onclick="javascript:_SFRESET_"><i class="fa fa-refresh"></i></button>
<button type="button" href="#" class="btn btn-outline-dark btn-sm" onclick="tags2.value=''"><i class="fa fa-eraser"></i></button>

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.