String defaultVal = '';
Schema.DescribeFieldResult objDF = Lead.Status.getDescribe();
List<schema.picklistentry> pickVals = objDF.getPicklistValues();
for (Schema.PicklistEntry pv: pickVals) {
if (pv.isDefaultValue()) {
defaultVal = pv.getValue();
break;
}
}
system.debug('Picklist Default value is' + defaultVal);
Loading...
deleteWhitespace()
is used to remove spaces from a string in Salesforce.
For Example:
String str = 'Hello World';
system.debug(str.deleteWhitespace()); //HelloWorld
Loading...
Controller:
public class PrintSample {
public List<account> objList {get; set;}
public PrintSample() {
objList = new List<account>();
objList = [SELECT Name, Phone FROM Account];
}
}
Visualforce Page:
<apex:page showheader="false" controller="PrintSample">
<apex:panelgrid width="100%" style="text-align:right;">
<apex:form>
<apex:commandlink value="Print" onclick="window.print();"></apex:commandlink>
</apex:form>
</apex:panelgrid>
<apex:pageblock title="Account Information">
<apex:pageblocktable value="{!objList}" var="a">
<apex:column value="{!a.Name}"></apex:column>
<apex:column value="{!a.Phone}"></apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:page>
Output:
Loading...
String recordId = '01I20000000VyKGAAN';
Id newId = Id.valueOf(recordId);
Note: Here String recordId
should be a valid record id. Salesforce Id is system generated Id and we cannot generate it.
Loading...
The below sample code is used to convert String to Date data type using Apex
String todate = '12/25/2015';
Date dt = Date.parse(todate);
Loading...