Activity Forums Salesforce® Discussions How to define the records to be returned by SOSL search?

  • Abhinav

    Member
    August 1, 2016 at 1:38 pm

    Hi Pranav,

    Journal__c je = new Journal__c();
    je.Name = 'Test';
    je.UserID__c = UserInfo.getUserId();
    // Add all required Field here
    insert je;

    PageReference myVfPage = Page.MyJournal;
    Test.setCurrentPage(myVfPage);

    Id [] fixedSearchResults = new Id[]{je.Id};
    Test.setFixedSearchResults(fixedSearchResults);

    Please make sure that you have used Test.setFixedSearchResults(); before calling any method of the class.

    I hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos