We have a solution that requires the Regarding field entities to be restricted based on an optionset (Selection Type).
This is being accomplished via the following javascript.
case "ACCOUNT SETUP AND MAINTENANCE":
Shared.SetLookupFieldFilter(formContext, "regardingobjectid", ['account', 'fst_customergroup', 'fst_salescontract']);
Shared.CheckRequestRegardingType('COMA - Contract Management', ['account', 'fst_customergroup', 'fst_salescontract']);
break;
case "CONTRACT AUDIT":
Shared.SetLookupFieldFilter(formContext, "regardingobjectid", ['fst_salescontract']);
Shared.CheckRequestRegardingType('COMA - Contract Management', ['fst_salescontract']);
break;
case "GLOBAL ID CREATION":
formContext.getControl("regardingobjectid").setVisible(false);
break;
case "GLOBAL ID REVIEW":
Shared.SetLookupFieldFilter(formContext, "regardingobjectid", ['fst_globalgroup', 'fst_salescontract']);
Shared.CheckRequestRegardingType('COMA - Contract Management', ['fst_globalgroup', 'fst_salescontract']);
break;
Shared.SetLookupFieldFilter = function(formContext, fieldName, entityArray) {
var lookupControl = formContext.getControl(fieldName);
if (lookupControl.getEntityTypes().length > 1) {
lookupControl.setEntityTypes(entityArray);
}
}
Everything seems to work correctly, until the optionset value is selected that only has one lookup entity. At that point, it filters to only that entity and disables the Look For drop down list. Any subsequent change of the Selection Type optionset to a value that has more than one lookup entity no longer works. It still displays the entity from the single filter.
Any thoughts or ideas on how to clear the lock on the Look For drop down, or enable the entity list to be applied correctly? I am unable to save, as the use may be in the middle of entering data into this custom request.
Thanks for your insight.