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];
}
SOQL: Bulk Fuzzy Searching salesforce
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
}
-------------------
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);
-----------------
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);
-----------------
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);
Visualforce Email Template
<messaging:emailTemplate subject="Action Required : After Event, Confirm the completion of Customer Meeting"
recipientType="User" relatedToType="Lead">
<messaging:htmlEmailBody >
<style>
table.mainBody {
border-spacing: 10px;
border-collapse: collapse;
border-radius: 25px;
margin-top: 30px;
}
span.highlight {
font-size: 10.0pt;
font-family: "Arial", "sans-serif";
color: #4F81BD;
font-weight: bold;
}
p {
font-family: "Arial", "sans-serif";
font-size: 10pt;
font-weight: normal;
margin-bottom: 10px;
margin-left: 40px;
width: 700px;
word-wrap: break-word;
}
</style>
<table id="topTableBody" cellpadding="10px" cellspacing="0" class="mainBody">
<tbody>
<tr valign="middle">
<td>
<p>
Dear {!relatedTo.LastName},
</p>
<p>Your body here
</p>
<p> Please
<apex:outputLink value="{!LEFT($Api.Partner_Server_URL_220, FIND( '/services', $Api.Partner_Server_URL_320))}a4N?fcf=00B340000090IWG">Click Here
</apex:outputLink> to confirm the attendees.
</p>
<p>
Regards,
<br/> SFDC Team
</p>
</td>
</tr>
</tbody>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
recipientType="User" relatedToType="Lead">
<messaging:htmlEmailBody >
<style>
table.mainBody {
border-spacing: 10px;
border-collapse: collapse;
border-radius: 25px;
margin-top: 30px;
}
span.highlight {
font-size: 10.0pt;
font-family: "Arial", "sans-serif";
color: #4F81BD;
font-weight: bold;
}
p {
font-family: "Arial", "sans-serif";
font-size: 10pt;
font-weight: normal;
margin-bottom: 10px;
margin-left: 40px;
width: 700px;
word-wrap: break-word;
}
</style>
<table id="topTableBody" cellpadding="10px" cellspacing="0" class="mainBody">
<tbody>
<tr valign="middle">
<td>
<p>
Dear {!relatedTo.LastName},
</p>
<p>Your body here
</p>
<p> Please
<apex:outputLink value="{!LEFT($Api.Partner_Server_URL_220, FIND( '/services', $Api.Partner_Server_URL_320))}a4N?fcf=00B340000090IWG">Click Here
</apex:outputLink> to confirm the attendees.
</p>
<p>
Regards,
<br/> SFDC Team
</p>
</td>
</tr>
</tbody>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
get fields dynamically from custom settings or field set salesforce
string query = 'Select ID';
for(Schema.FieldSetMember f :SObjectType.Campaign.FieldSets.SST_CampaignFields.getFields()){
query = query + ', '+f.getFieldPath();
}
query = query + ' from campaign limit 10';
system.debug('Queury : '+query);
List<Campaign> camp = database.query(query);
system.debug('Queury : '+camp);
for(campaign c : camp){
system.debug('Queury : '+c);
}
for(Schema.FieldSetMember f :SObjectType.Campaign.FieldSets.SST_CampaignFields.getFields()){
query = query + ', '+f.getFieldPath();
}
query = query + ' from campaign limit 10';
system.debug('Queury : '+query);
List<Campaign> camp = database.query(query);
system.debug('Queury : '+camp);
for(campaign c : camp){
system.debug('Queury : '+c);
}
Subscribe to:
Comments (Atom)
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
-
Apex Snippet : ----------------- Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(new String[]{'Lead'}); ...
-
A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...
-
Child Component Code Snippet : AuraMethodChildCMP.cmp <aura:component implements="force:appHostable,flexipage:availableForAllPag...