Activity Forums Salesforce® Discussions Can we write sosl in triggers in salesforce?

  • Suraj

    Member
    April 24, 2017 at 12:37 pm

    Hi Saurabh,

    Yes, you can write SOSL inside triggers.There is no such restriction.

    You can test using the following Code in your Org.
    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);
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos