SOQL: Bulk Fuzzy Searching salesforce

public static List<Account> findCandidates(String potentialName){
    if (String.isBlank(potentialName)) return null;
    List<Account> candidates = [SELECT Id FROM Account WHERE Name = :potentialName];
    if (!candidates.isEmpty()) return candidates;

    List<String> partialMatches = new List<String>();
    for (String fragment : potentialName.split(' ')){
        partialMatches.add('%' + fragment + '%');
    }
    return [SELECT Id FROM Account WHERE Name LIKE :partialMatches];
}

Pass Variable From JavaScript Function on Open.WIndow

HTML Snippet :
-------------------

onclick="return drilldown('{!line.paramvalue}')"

Java Script Snippet:
-----------------------

function drilldown( dilldownparam ) {
  var w = window.open('/apex/CompetencyDrillDownPage?testvalue='+dilldownparam, target='_blank')
  return false
}

List of errors in visualforce page salesforce

VF :
-----

<apex:page standardController="Contact" extensions="SKT_ErrorListPage_CLS">
     <apex:form >
         <apex:pageMessages escape="false" id="messages"></apex:pageMessages>
         <apex:pageBlock title="Contact Details">
             <apex:pageBlockSection >
                 <apex:inputField value="{!con.lastname}"/>
                 <apex:inputField value="{!con.LeadSource}"/>
                 <apex:inputField value="{!con.Level__c}"/>
                 <apex:inputField value="{!con.Status__c}"/>
                 <apex:inputField value="{!con.Applcation__c}"/>
                 <apex:inputField value="{!con.Monday_Shift__c}"/>
                 <apex:inputField value="{!con.CallBackTime__c}"/>
                 <apex:inputField value="{!con.phone}"/>
             </apex:pageBlockSection>
             <apex:pageBlockButtons >
                 <apex:commandButton value="Submit" action="{!cmdSubmitButton}"/>
             </apex:pageBlockButtons>
         </apex:pageBlock>
     </apex:form>
</apex:page>

Apex:
-----

public with sharing class SKT_ErrorListPage_CLS{
    public contact con {get;set;}
    public SKT_ErrorListPage_CLS(ApexPages.StandardController controller){
        con = new contact();
    }
    public List < String > lstErrors = new List < String > ();
    public Integer errorCount = 0;
    public pagereference cmdSubmitButton(){
    try{
         lstErrors.clear();
         errorCount = 0;
         if(con.Level__c != NULL || con.Level__C != '--None--'){
             if(con.Level__c !='Primary' ){
                 errorCount = 1;
                 lstErrors.add('Level always primary only');                 
             }
         }
         if (con.Status__c == 'Call in Progress') {
             errorCount = 1;
             lstErrors.add('Please select Valid Disposition Value');
         }else if(con.Status__c == 'Call Back' || con.Status__c =='Nurture'){
             if(con.CallBackTime__c == NULL){
                errorCount = 1;
                lstErrors.add('Please provide Call Back Time');
            }else if(con.CallBackTime__c < System.Now()) {
                errorCount = 1;
                lstErrors.add('Call Back Time must be  future date/time.');
            }
         }
         if(con.phone == NULL){
             errorCount = 1;
             lstErrors.add('Please provide valid phone');
         }
         if(con.leadsource<>'SKTT'){
             errorCount = 1;
             lstErrors.add('Please provide Lead Source as SKTT');
         } 
         if (errorCount > 0){
            lstErrors.sort();
            processError(lstErrors);
            return null;
        }else{
            insert con;
            //id cuId = con.id;
            return new pagereference('/'+con.id);
        }     
    }catch(exception e){
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
        return null;
    }
    }
    public String stringError;
    public void processError(List < String > lstErrors) {
        stringError  = '<font color="red"> Input Requried for <ul style="color: red;">';
        for (String error: lstErrors) {
            stringError += '<li>' + error + '</li>';
        }
        stringError += '</ul></font>';
        ApexPages.Message myErrors = new ApexPages.Message(ApexPages.severity.Info, stringError);
        ApexPages.addMessage(myErrors);
    }
}


Screenshot:
----------------



Getting All object fields dynamically without adding each and everything salesforce

Apex Snippet :
-----------------

Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(new String[]{'Lead'});      
Map<String, Schema.SObjectField> fsMap = descResult[0].fields.getMap();
List<String> fieldNames = new List<String>(fsMap.keySet());
String queryString;
for(String f:fieldNames){
    queryString = 'SELECT '+String.join(fieldNames,',')+' FROM Lead limit 1';
}
System.debug(queryString);
SObject obj = Database.query(queryString);
System.debug(obj);


Getting All object fields dynamically without adding each and everything salesforce

Apex Snippet :
-----------------

Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(new String[]{'Lead'});      
Map<String, Schema.SObjectField> fsMap = descResult[0].fields.getMap();
List<String> fieldNames = new List<String>(fsMap.keySet());
String queryString;
for(String f:fieldNames){
    queryString = 'SELECT '+String.join(fieldNames,',')+' FROM Lead limit 1';
}
System.debug(queryString);
SObject obj = Database.query(queryString);
System.debug(obj);


Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular