Long Text Field Limitations

There are some actions in SF which cannot use long text fields.
For example:
* Filters in look up window.
* Filter in where clauses in SOQL.
* Track history for those fields value (SF can only track that the field has been changed).

Kind of workaround for this issues is to create another text field which contain the first 255 characters (or keyword) of the original long text, and use it in all relevant processes.

It's not perfect, but for many cases it will suffice.


I'll demonstrate it with 2 custom objects I created:
1.Author
2.Book

The Author have look up field to Book (Favourite Book), and in the look up I want
to allow filtering by long text field - description.

So I'll use the above workaround:


1.Create String field - short description






2.Create work flow + field update to populate this new field from the long text field.





3.Add the Short Description field to the filter fields.





In case you don't see this Lookup Filter Fields section in the object:
go to Setup -> App Setup --> Customise -->Search -->Search Settings

In the Lookup Settings select the check box in 'Enhance Lookup' for the relevant object.


4.Result: you can use the short description field to filter.




In addition, you can use the short description field for the other processes that mentions at the beginning (track history, SOQL query).





Generic Mass Edit Page

Hi,

This is really nice piece of code that can be reuse for any object.
The following visual page allow you to mass edit many records quickly with javascript.
Any comment will be appreciate.

1.Usage:
Build the URL as follow:
/apex/MassEditPage?ids= < list of records ds seperated by :> &obj= <object API name> &fSet= <fields set for the object>

Parameters:
ids - is the records ids that you want to edit seperated by ':'
obj - abject API name of the records you updating
fSet - field set of the fields you want to modify.

2.functionality:
The functionality is to display list of records in page block table, and above single "dummy" record, that allowing to use mass edit. each time a field in the "dummy" record is changed we run javascript code to change the corresponding field in the list.




3.Field set:
The use of field Set (the third parameter in the URL) allowing the page to work dynamically, and of course allowing also for update the list of editable fields without changing the code.

How to create Field Set?



public class vf_MassEditPage   {  
 
 public list<sObject> objLst {get; set;}               //list of object to update  
 public list<String> objFieldLst {get; set;}          //list of fields in the object  
 public map<String, String> fieldAPI_Label {get; set;}  
 public list<sObject> dummyObjLst {get; set;}     //list with 1 object- use for mass update in the page  

 public vf_MassEditPage()  {  
  
  objFieldLst=new list<String>();  
  fieldAPI_Label=new map<String, String>();  

  //collect the object id from URL  
  list<String> objidLst=new list<String>();  
  for (String id : ApexPages.currentPage().getParameters().get('ids').split(':'))  {
   objidLst.Add(id);  
  }

  String objName=ApexPages.currentPage().getParameters().get('obj');  
  String fieldSetName=ApexPages.currentPage().getParameters().get('fSet');  

  Schema.SObjectType sObjectTypeObj = Schema.getGlobalDescribe().get(objName);  
  Schema.DescribeSObjectResult describeSObjectResultObj = sObjectTypeObj.getDescribe();  
  Schema.FieldSet fieldSetObj = describeSObjectResultObj.FieldSets.getMap().get(fieldSetName);  

  //build sql to get all the objects  
  String sql='SELECT id';  
  for(Schema.FieldSetMember field : fieldSetObj.getFields())  {  
   sql+=',' + field.getFieldPath();  
   objFieldLst.add(field.getFieldPath());  
   fieldAPI_Label.put(field.getFieldPath(), field.getLabel());  
  }  
  sql+=' FROM ' + objName + ' WHERE id in : objidLst';  

  objLst=Database.query(sql);  

  dummyObjLst=new list<sObject>{sObjectTypeObj.newSobject()};  
 }  

 public PageReference saveData()  {  
  try  {  
   update objLst;  
  }  
  catch(Exception e)  {  
   ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while saving ' + e));  
  }  
  return ApexPages.currentPage();  
 }  
}  


page:

<apex:page controller="vf_MassEditPage" sidebar="false" id="pageid">  

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  
 <script type="text/javascript">  

  function updateAll(inputComp, fieldTarget)  {  
   var inputElem = document.getElementsByTagName("input");  
   for(var i=0; i < inputElem.length; i++)   {  
    if (inputElem[i].className == 'cls_' + fieldTarget)   {  
     inputElem[i].value = inputComp.value;  
    }       
   }  
  }  
 </script>  

 <apex:form id="frm">  
  <apex:pageMessages id="errors" escape="false" />  
  <apex:pageBlock mode="edit" id="results">  
   <apex:pageBlockButtons location="top" id="buttons">  
    <apex:commandButton id="Save" value="Save" action="{!saveData}" />  
   </apex:pageBlockButtons>  

   <apex:pageBlockTable value="{!dummyObjLst}" var="obj" id="editLst1" >  
    <apex:repeat value="{!objFieldLst}" var="fieldName" id="editLst2">  
     <apex:column headerValue="{!fieldAPI_Label[fieldName]}">  
      <apex:inputField value="{!obj[fieldName]}" onChange="updateAll(this, '{!fieldName}')"/>  
     </apex:column>  
    </apex:repeat>  
   </apex:pageBlockTable>  

   <apex:pageBlockTable value="{!objLst}" var="obj" id="objData1" >  
    <apex:repeat value="{!objFieldLst}" var="fieldName" id="objData2">  
     <apex:column >  
      <apex:inputField styleClass="cls_{!fieldName}" value="{!obj[fieldName]}"/>  
     </apex:column>  
    </apex:repeat>  
   </apex:pageBlockTable>  
  </apex:pageBlock>  
 </apex:form>  
</apex:page>  

Retire of Permission on Profiles

If you are working as a Salesforce admin/developer you've probably heard somewhere that Salesforce is planning to make a significant cha...