web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to change default ...
Power Pages
Suggested Answer

How to change default List with Search enabled from "Begins With" to "Contains Logic"

(0) ShareShare
ReportReport
Posted on by
Hi Community, 
 
I have a list view of one of my data tables in my power page and search is enabled. I noticed that if I search with it, only columns where the data starts with the search query are detected and displayed in the results. I assume this is "Begins With" logic. I need "Contains" logic applied for my search bar so that all relevant results are displayed. A quick workaround I have found is adding asterisks in front and at the end of a query string so that it imitates Contains logic when displaying results. However, I would like suggestions on a permanent solution where users won't have to manually add asterisks or see any in the search bar.
 
I have some Javascript I wrote in the List to automatically add asterisks to the search query after the Search button or Enter is clicked, but it still shows up in the search bar as seen in the image attached below. If there is a way to edit my code so that the asterisks won't be seen by the user. this would also be appreciated. 
 
My code in the List options in Power Pages Management: 
// Wait for the input to appear before binding event listeners  
function waitForElement(selector, callback, timeout = 5000) {  
  const start = Date.now();  
  const interval = setInterval(() => {  
    const element = document.querySelector(selector);  
    if (element) {  
      clearInterval(interval);  
      callback();  
    } else if (Date.now() - start > timeout) {  
      clearInterval(interval);  
      console.warn(`Element ${selector} not found within ${timeout}ms`);  
    }  
  }, 100);  
}  
 
waitForElement(".entitylist-search input.query", function () {  
  const input = document.querySelector(".entitylist-search input.query");  
  const button = document.querySelector(".entitylist-search .input-group-btn button");  
 
  if (input && button) {  
    console.log("Search input and button found!");  
 
    // Store original event handlers
    const originalButtonHandler = button.onclick;
    const originalFormHandler = input.form ? input.form.onsubmit : null;
 
    // Override button click
    button.onclick = function(e) {
      // Add asterisk if needed
      if (input.value && !input.value.startsWith("*")) {  
        input.value = "*" + input.value + "*";  
      }
       
      // Call original handler if it exists
      if (originalButtonHandler) {
        return originalButtonHandler.call(this, e);
      }
    };
 
    // Override form submission if form exists
    if (input.form) {
      input.form.onsubmit = function(e) {
        // Add asterisk if needed
        if (input.value && !input.value.startsWith("*")) {  
          input.value = "*" + input.value + "*";  
        }
         
        // Call original handler if it exists
        if (originalFormHandler) {
          return originalFormHandler.call(this, e);
        }
      };
    }
 
    // Handle Enter key
    input.addEventListener("keydown", function(e) {
      if (e.key === "Enter") {
        // Add asterisk if needed
        if (input.value && !input.value.startsWith("*")) {  
          input.value = "*" + input.value + "*";  
           console.log("input edited");  
        }
        // Let the event continue naturally
      }
    });
 
  } else {  
    console.warn("Input or button still not found.");  
  }  
});
 
Thanks!
Screenshot 2025-10-14 113038.png
Categories:
  • Suggested answer
    Jerald Felix Profile Picture
    387 Super User 2026 Season 1 on at

    To switch your Power Pages list search from "Begins With" to "Contains" logic without users adding asterisks manually, use a custom FetchXML query for the list's view. This applies a contains filter (like with %) server-side, overriding the default behavior—no JS tweaks needed, and it stays OOB.
     
    Quick Setup
    • In Power Apps maker portal, go to Solutions > your solution > Tables > your entity > Views > create/edit the view used in your list.
    • Click Edit FetchXML (or download from Advanced Find, edit, re-upload).
    • Replace the default filter with a contains clause on searchable fields (e.g., Name, Description). Example for a view filtering on Name:
    • <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
        <entity name="yourentity">
          <attribute name="name" />
          <attribute name="description" />
          <order attribute="name" descending="false" />
          <filter type="and">
            <condition attribute="name" operator="like" value="%{searchterm}%" />  <!-- % for contains -->
          </filter>
        </entity>
      </fetch>
      
       
      • %searchterm% uses the search input as a wildcard (contains logic). Add more <condition> for multiple fields (e.g., Description with like).
      • Save and activate the view.
    • In Power Pages design studio: Edit your list > Settings > View > select this custom view.
    • In Portal Management: Entity Lists > your list > Views > add the view, set as default, and enable search (it'll now use the FetchXML filter).​
    • Publish and test—search "Hope" will find "Coast Hope" without asterisks.

       
    For multi-field search, chain conditions with or in the filter. If your entity has many records, this keeps it performant as it's server-side. Your JS works as a fallback, but to hide asterisks: In the code, clone the input value for submission (store original, revert after), e.g., add let originalValue = input.value; before modifying, then input.value = originalValue; after the handler runs.​

    I hope it will help you to resolve your issue.
     
    Many Thanks!
     
    Best Regards, 
    Jerald Felix
     
  • Suggested answer
    Fubar Profile Picture
    17 Super User 2026 Season 1 on at
    Please refer to Oliver's blog post regarding wildcard search that will work, he also makes use of the lists 'loaded' event rather than interval timers.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 20

#2
11manish Profile Picture

11manish 18 Super User 2026 Season 2

#3
DianePana Profile Picture

DianePana 9

Last 30 days Overall leaderboard