Filter Lookups on MSD 365

  • Out of box filter No Code: This just configuration on form.
  • Simple Lookup filter
function AddCustomFilterToLookup(formContext, fieldName, lookuptypes) {

//below fetchxml will be a custom filter to the lookup 
    var fetchxml = "<filter type='and'><condition attribute='ownerid' operator='eq-userid'/></filter>";
    formContext.getControl(fieldName).addCustomFilter(fetchxml, lookuptypes[0]);
}
  • Regarding Object lookup filter

//here fieldName = "regardingobjectid";
//     lookuptypes = ["contact", "account", "soft_cust_EntityName", "incident"];
//     formContext = executionContext.getFormContext(); 
function RegardingObjectFilter(formContext, fieldName, lookuptypes) {
    var control = formContext.getControl(fieldName);
    control.setEntityTypes(lookuptypes);
}

That’s it for now. Thanks!! 🙂