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 '#').
When we try to change the owner, we see all of these system generated accounts.
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.
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.
WarrenBelz
75
Most Valuable Professional
mmbr1606
51
Super User 2025 Season 1
MS.Ragavendar
36