Posts

Showing posts from January 19, 2017

Standard Pagination Using Standard Controller based on RecordSetVar

Image
<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" sidebar="false">     <apex:form >             <apex:pageBlock title="Edit Opportunities" >             <apex:pageMessages ></apex:pageMessages>             <apex:pageBlockButtons >               <apex:commandButton value="Save" action="{!save}"/>               <apex:commandButton value="Cancel" action="{!cancel}"/>             </apex:pageBlockButtons>             <apex:pageBlockTable value="{!opportunities}" var="opp">                 <apex:column value="{!opp.name}"/>                   <apex:column headerValue="Stage">                     <apex:inputField value="{!opp.stageName}"/>                   </apex:column>                   <apex:column headerV

Get list of Key Prefix of Sobject in Salesforce

Image
Requirement:  Show the list of Key Prefix of Sobject in salesforce Solution: Class Code: public class populateObjectsAndKeyPrefixController {      public List<Schema.SObjectType> lstofSType {get;set;}       public List<SObjectInfo> lstofSobject {get;set;}           public class SObjectInfo {         public String prefix {get;set;}         public String name {get;set;}     }        public gettingObjectsAndKeyPrefix(){                        lstofSType  = Schema.getGlobalDescribe().Values();         lstofSobject = new List<SObjectInfo>();         for(Schema.SObjectType f : lstofSType )         {             SObjectInfo sobjectinfo = new SObjectInfo();            sobjectinfo.prefix = f.getDescribe().getKeyPrefix();             sobjectinfo.name = f.getDescribe().getLabel();             lstofSobject.add(SObjectInfo);         }             } } VF Page Code <apex:page controller="populateObjectsAndKeyPrefixController "

Find Day of selected Date on VF Page

Image
Requirement: Find the day of selected date in date field Solution: public class DayOfDate {     Private Date startDate = date.newInstance(0001, 1, 1);        Public Date selectedDate{get;set;}     public String dayValue{get;set;}     public Account acc {get;set;}     public DayOfDate()     {           system.debug('startDate***'+startDate);         selectedDate = date.today();         system.debug('selectedDate*****'+selectedDate);         acc = new Account();     }     public void calculateDayOfDate()     {         List<String> listDay = new List<String>{'Saturday' , 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday'};         selectedDate = acc.SLAExpirationDate__c;         Integer remainder = Math.mod(startDate.daysBetween(selectedDate) , 7);         system.debug('remainder____'+remainder);         dayValue = listDay.get(r