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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filtering the record o...
Power Apps
Unanswered

Filtering the record owners in the header of a form

(0) ShareShare
ReportReport
Posted on by 223

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
    223 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard