Before 2 days back when we were solving production issue I realized
knowledge in not enough, you must apply. The issue was one of our trigger was
working when records are get created from Salesforce Org but It’s was not
working when records are created from Customer Portal. Trigger is firing but it’s not working when
records are getting created from portal.
After spending 30 min we realized power of with sharing
Keyword. Our trigger handler class marked as with sharing. So sharing rules are
getting applied and Some SOQL queries returns zero record and trigger get
failed L
and make me sad.
Even I was aware of with sharing and without sharing. I did
mistake which cost 30 min and one production blocker.
So what is the base line? Trigger Handler class “without
sharing” keyword can save your 30 min.
Note: All SOQL or SOSL queries that use PriceBook2
ignore the with sharing keyword