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
samrat.1985@lntinfotechsamrat.1985@lntinfotech 

Include RichText Area field in a formula field.

I need to implement search across 3 custom objects which are linked with each other using look-up fields. The search query (SOQL query) will be only on that formula field ( e.g.. Select * from <Custom object> where <formula field> like ‘% search keyword%’ ). 

The limitation of the formula field and the where clause of the select(SOQL) query is it doesn’t allow Rich Text area fields to be included i.e.. We can neither include Rich Text Area field in the formula field nor can be included in the WHERE clause. Unfortunately I have quite a lot Rich Text Area fields which is supposed to be part of the search scope. How can I achieve this in this current scenario.

 

I need a work around fast please help me

samrat.1985@lntinfotechsamrat.1985@lntinfotech

Regarding my earlier query to include Rich Text Area, Long Text Area fields in formula field or Where condition, I think the formula field or where clause will not work. So we need to use the SOSL query which is basically a Search API provided by salesforce.com for search purpose. But the limitation of SOSL query is it doesn’t work on the lookup fields and in our case we want the search to go and search from the lookup fields objects also

 

Use separate Search call for each of the objects (parent object as well as objects which are referred by lookup fields) and merge the search result and remove the duplicates. You can create the similar scenario in your dev environment by following this:

Object 1 – Field1 (Number)

                    Field2 (Text)

                    Field3 (Long Text Area)

                    Field4 (Lookup field Object2 – field 2)

                    Field5 (Lookup field Object3 – field 1)

                    Field6 (Picklist)

Object 2 – Field1 (Number)

                    Field2 (Text)

                    Field3 (Long Text Area)

                    Field4 (Rich Text Area)                   

Object 3 – Field1 (Number)

                    Field2 (Text)

                    Field3 (Long Text Area)

                    Field4 (Rich Text Area)

 

Following columns should be part of the scope of the search:

Object1 – All the columns

Object2- Field2, Field3, field4

Object2- Field2, Field3, field4

 

The search result would be a result set of all the columns from Object1 and field2,3,4 from Object 2 and 3.

samrat.1985@lntinfotechsamrat.1985@lntinfotech

This is my search page

 

<apex:page id="pg" controller="searchController" showheader="true" >
<head>
<base target="_parent" />

</head>
<apex:form id="frm"><apex:pageBlock >
<apex:pageBlockSection title="Seach Criteria" showHeader="true" columns="2">

<apex:inputText id="searchStr" value="{!srchText}"/>

<apex:commandButton value="Search" action="{!Populate}">
</apex:commandButton>
</apex:pageBlockSection>
</apex:pageBlock>

<!------Search Result---->
<apex:pageBlock >
<apex:pageBlockSection title="Search Result" showHeader="true" columns="1">
    <apex:pageBlockTable value="{!res}" var="a">  
        <apex:column >
                </apex:column>
        <apex:column value="{!a.Field_1__c}" >
        <apex:facet name="header">
         <apex:outputText value="Object A Number"></apex:outputText>
    </apex:facet>

</apex:column>
                <apex:column value="{!a.Field_2__c}">
            <apex:facet name="header">
             <apex:outputText value="Object A Text"></apex:outputText>
            </apex:facet>
        </apex:column>
        <apex:column value="{!a.Field_3__c}">
            <apex:facet name="header">
             <apex:outputText value="Object A TextArea(Long)"></apex:outputText>
            </apex:facet>
        </apex:column>
        <apex:column value="{!a.Field_4__c}">
            <apex:facet name="header">
             <apex:outputText value="Object B lookup"></apex:outputText>
            </apex:facet>
        </apex:column>
         <apex:column value="{!a.Field_5__c}">
            <apex:facet name="header">
             <apex:outputText value="Object C lookup"></apex:outputText>
            </apex:facet>
        </apex:column>
                          </apex:pageBlockTable>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

 

Following is my Controller

public class searchController {
     
      List<List<SObject>> searchList;
       public String srchText ;
       Object_A__c [] res;
        Object_B__c [] res1;
        Object_C__c [] res2;

      
public String getsrchText()
{
  return srchText;
}

public void setsrchText(String newTD)
{
   srchText=newTD;
}

public PageReference Populate()
{
     
   
      String id=srchText;
 
     
     searchList = [FIND :id IN ALL FIELDS
                                     RETURNING
                                     Object_A__c (Field_1__c, Field_2__c,Field_3__c,Field_4__c,Field_5__c),
                                     Object_B__c (Field_1__c,Field_2__c,Field_3__c,Field_4__c),
                                     Object_C__c (Field_1__c,Field_2__c,Field_3__c,Field_4__c)
                                      ];
    
     res= ((List<Object_A__c>)searchList[0]);
     res1=((List<Object_B__c>)searchList[1]);
      res2=((List<Object_C__c>)searchList[2]);
    
     system.debug('Object_A__c' + res);
     system.debug('Object_B__c' + res1);
     system.debug('Object_C__c' + res2);


 return Page.Search;


}
public LIST<Object_A__c> getres()
{
      
   return res;
}

public LIST<Object_B__c> getres1()
{
      
   return res1;
}
public LIST<Object_C__c> getres2()
{
      

   return res2;
}

}

 

 

Now the catch here is i want res,res1,res2 to be merged and i can get all the results in one result set. So that i can display the selected columns as i feel.

But i am unable to do so please help

WizradWizrad

I barely ever use SOSL but can do you 3 SOSL queries and combine the results?