How to skip salesforce lookup filter?
How to Avoid Performing a Salesforce Lookup Filter Uses a Picklist?
There are many scenario user don’t want to fire lookup filter like while running some apex job or generating billing related record.
How to skip lookup filter?
- Create a checkbox field on the User object.
2. Go to lookup filter and add below condition along with existing condition
3. While starting a batch job update current user with Skip lookup Filter flag to “TRUE”
list<User> lstUser = [Select ID, Skip_Lookup_Filter__c from User where ID =:UserInfo.getUserId()]; for(User iterator: lstUser) { iterator.Skip_Lookup_Filter__c = True; } Update lstUser;
4. On finish method update the user Skip Lookup Filter flag to “False”
list<User> lstUser = [Select ID, Skip_Lookup_Filter__c from User where ID =:UserInfo.getUserId()]; for(User iterator: lstUser) { iterator.Skip_Lookup_Filter__c = false; } Update lstUser;
Note: Keep in mind – While batch job is running at the same time user trying to create some record manually the lookup filter will not fire since skipped filter for that user.
Pingback: How to Avoid Performing a Salesforce Lookup Fil...
April 11, 2022