function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LaurentDelcLaurentDelc 

How to Test the Document SOSL search?

Hi,

 

We have a SOSL request that goes threw the documents:

 

for(Document doc:(List<Document>)[FIND :keyword1 IN ALL FIELDS RETURNING Document(id)][0]){System.debug(doc);}

 

 To test that we need to inser a Document object.

We use this code:

 

Document d = new Document(); d.Name = 'my text file'; String myContent = 'aabbcc'; d.Body = Blob.valueOf(myContent); d.ContentType = 'text/plain';d.Type = 'txt';insert d;

 But the document is never retrieved by the SOSL request. 

This works fine inside our project with Document uploaded threw the Document Tab.

 

We noticed that our document's field IsBodySearchable is false which might cause the problem.

 

But how to put it to true when you manually insert from a Test class?

 

Thanks,

 

Laurent 

 

 

 

WesNolte__cWesNolte__c

Read the 'Testing is tricky' link here.

 

Wes