Can we write SOSL statements in triggers
Yes, we can write SOSL inside triggers.There is no such restriction.
Code:
trigger trg_AccountSOSL on Account (before insert, before update) {
List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead]; List<account> myAcc = ((List<Account>)searchList[0]); system.debug(myAcc[0].name); }
No comments:
Post a Comment