Hi Savik,
There are 2 ways to approach your requirement.
1. OOB
Navigate your Organisation entity and click its view menu, create a new view and Edit Filter Criteria, it will give filtered result with your criteria. (It's easy to edit)
Then in your Organisation form, select the Key Supplier field and edit it properties, scroll down to bottom and select the previous created view as Default View and set it to be only selected(presented) view in this Lookup field.
2. By script
You could add Script with 2 client API to filter results in lookup field:
they are addCustomFilter and addPreSearch function,
the first function is to add our filter, while the second one calls our filter to work, you should combine them in same code logic.
function filterOrganisationLookup() {
try {
// Get the Key Supplier lookup field and apply our filter function to it.
Xrm.Page.getControl("new_KeySupplier").addPreSearch(function () {
addCustomLookupfilter();
});
} catch (e) {
throw new Error(e.message);
}
}
function addCustomLookupfilter() {
try {
// fetchXml is our criteria
fetchxml = "<filter>" + "<condition attribute='new_organisation type"' operator='eq' value = 'Suppliers' />" + "</filter>";
Xrm.Page.getControl(" new_KeySupplier").addCustomFilter(fetchxml, "new_organisation");
}
catch (e) {
throw new Error(e.message);
}
}
Finally let filterOrganisationLookup function execute when Organisation Form OnLoad,
please read this article for how to add JavaScript to form.
Notes:
1. You should set parameter in getControl(" ") method to Name attribute to access your Lookup field.
2. It's same for entity you add filter and its attribute.
Regards,
Clofly