Another Salesforce blog!!!

Salesforce, Apex


concatenate using string.join

List<String> messages = new List<String>(); messages.add(‘one’); messages.add(‘two’); messages.add(‘three’); Employee__c emp = [SELECT Id,Emp_Message__c FROM Employee__c WHERE Id =: empId limit 1 ]; emp.Emp_Message__c += ‘,’ + String.join(messages, ‘,’); update emp; Favorite

enum in APEX

global with sharing class My_Controller { public Case currCase {get; set; } public enum StatusValue {RED, YELLOW, GREEN} public StatusValues getColorStatus() { return StatusValue.RED; //demo code – just return red } } <apex:image url=’stopsign.png’ rendered=”{!colorStatus == StatusValue.RED}” /> Favorite

Dynamically access Custom Labels from Apex Class

Retrieve Salesforce custom label dynamically in Apex Ever wonder if it is possible to retrieve custom labels dynamically but not sure whether it is possible? Well, the answer is yes. You can retrieve custom labels dynamically. Here is how you can achieve it. You just need to integrate the following code in your apex class. […]

find the object name by passing id

Id myId = ‘a0141000007TF4D’; system.debug(myId.getSobjectType().getDescribe().getName()); Favorite

!= null or !isEmpty() ?

Is this in regards to String? If so, I usually use String.isBlank( stringToCheck ). This checks for null, empty and all whitespace. If this is in regards to collections, you might have to check both: if ( myList != null && !myList.isEmpty() ) … If you know that your collection is not null (because you […]


Enterprise WSDL A strongly typed WSDL for customers who want to build an integration with their organization only. Generate Enterprise WSDL Partner WSDL A loosely typed WSDL for customers, partners, and ISVs who are building client applications for multiple organizations. It can be used to access data within any organization. Generate Partner WSDL Source […]

Invoking HTTP Callouts – GET

I will be using this endpoint link as a test purpose its very simple nothing fancy but the point is to prove how to get connected to this end-point and get access to the data. Step one: Add to the Remote site setting in the Salesforce as shown below. Step two: Create Custom Labels and […]

apexpage message utility

public static PageReference showMessage(String message, String msgType) { ApexPages.Message msg; if(msgType == ‘Error’) { msg = new ApexPages.Message(ApexPages.Severity.ERROR, message); //error } else{ msg = new ApexPages.Message(ApexPages.Severity.INFO, message); //info } ApexPages.addMessage(msg); return null; } To use: <apex:pageMessages ></apex:pageMessages> showMessage(‘At least ‘ + count + ‘ responses required’, ‘Error’); Favorite

how to retain the checkbox selection in visualforce pagination

First off; create a wrapper class in this example I’ll be using Account standard object: Overall big picture: First on the Visualforce page create apex function with two params. Create a SET variable of id’s(Set some name = new Set) Create two properties (get; set; method properties) for Id and another for boolean. Now the […]

AD hoc soql query

Constructor: public List<String> lst1Fields {set;get;} public List<String> lst2Fields {set;get;} public List<String> lst3Fields {set;get;} List<custom_object__c> listCustomObject = [soql]; for(custom_object__c c: listCustomObject) { if(string.isEmpty(c.field__c)) { lst1Fields.add(c.field_name); } } public PageReference searchNow(){ String qryStr = ‘SELECT Id’; String conditionStr = ‘ WHERE Name_ID__c = \”+ searchWord +’\” + ‘ OR Name_ID__c LIKE ‘+’\”+ searchWord +’\”; for(String searchField : […]

Previous Posts Next posts