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 Apps / Filtering the record o...
Power Apps
Answered

Filtering the record owners in the header of a form

(0) ShareShare
ReportReport
Posted on by 225

Hi All

 

We currently have a request to filter the owner search pane within a form to only display user accounts, not accounts that are created by the system (including the '#').

NativeNass__0-1695973453659.png

 

When we try to change the owner, we see all of these system generated accounts.

NativeNass__1-1695973569560.png

 

sidenote: editing the lookup view of the user table is not an option because then this would be applicable to all applications within this environment, it only needs to be on this specific form so as far as we know, JavaScript is the only way.

 

The JS we implemented on the onLoad event of the complete form is the following;

 

function onChangeOwner() {
var Sdk = window.Sdk || {};


Sdk.setOwnerIdFilter = function (executionContext) {

 // get the form context
 formContext = executionContext.getFormContext();
 formContext.getControl("header_ownerid").addPreSearch(Sdk.filterOwnerId);
}

Sdk.filterOwnerId = function () {

 var ownerIdFilter = "<filter type='and'><condition attribute='fullname' operator='not-begin-with' value='#' /></filter>";
 formContext.getControl("header_ownerid").addCustomFilter(ownerIdFilter, "systemuser");
}
}

 

but we can't get it to work, it keeps showing all of the users when searching.

 

Thanks for the help and sorry if I define myself to be a little unclear, still figuring out the customizations of Model Driven Apps.

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    Try the following code out:

    function onLoad(executionContext) {
     var formContext = executionContext.getFormContext();
     formContext.getControl("header_ownerid").addPreSearch(filterOwnerId);
    }
    
    function filterOwnerId(executionContext) {
     var formContext = executionContext.getFormContext();
     var ownerIdFilter = "<filter type='and'><condition attribute='fullname' operator='not-begin-with' value='#' /></filter>";
     formContext.getControl("header_ownerid").addCustomFilter(ownerIdFilter, "systemuser");
    }

     

    Add onLoad to handle the Load event of the form and don't forget to check "Pass Execution Context as First Parameter" checkbox.

  • NativeNass_ Profile Picture
    225 on at

    @a33ik 

     

    Thanks a lot!

    This works!

     

    Thank you for your help & kind regards

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard