Another Salesforce blog!!!

Salesforce, Apex

December, 2016

Validation Rules

Budget Known must be Checked. AND( Budget_known__c= false ) Can we win this opportunity must be “Yes”, if “No”, Can we win this opportunity Desc cannot be null. AND(Can_we_win_this_opportunity__c = false,Can_we_win_this_opportunity_reason__c= “”) Contract Signed must be Checked. if StageName = ‘Negotiations’ IF( ISPICKVAL( StageName, ‘Negotiations’),Contract_signed_both_parties__c= false, False) Product and Pricing Multi-Select Picklist must have at […]

Converting GMT into Locale Users Time Zone

String timeZone = UserInfo.getTimeZone().getID(); Datetime dateGMT=System.now();// here you can user your dates e.g. createddate Datetime d1=Datetime.valueOf(dateGMT); string s1=d1.format(); System.debug(‘@@@@@@@@@@@’+s1);

TimeZone with Visualforce page date/time

Some months ago I had a project where I needed to show what date and time an order was processed in Eastern regardless of who submitted the order and their related timezone. Google will quickly show the light for how to display date/time using the timezone set on the user profile or GMT. So the […]

Object fields limit

800 per object for Performance and Unlimited editions; 500 per object for Enterprise and Developer editions; 100 per object for Professional and Group editions; 25 per object for Contact Manager edition; and 5 per object for Personal edition. http://resources.docs.salesforce.com/204/14/en-us/sfdc/pdf/salesforce_app_limits_cheatsheet.pdf

Counting how many fields I have available on an object

integer FieldCount = account.sObjectType.getDescribe().fields.getMap().size(); system.debug(‘//’+ FieldCount);

Please wait message

<apex:page standardController=”Account”> <style> /* This is for the full screen DIV */ .popupBackground { /* Background color */ background-color: black; opacity: 0.20; filter: alpha(opacity = 20); /* Dimensions */ width: 100%; height: 100%; top: 0; left: 0; z-index: 998; position: absolute; /* Mouse */ cursor:wait; } /* This is for the message DIV */ .PopupPanel […]

Pagination using StandardSetController

<apex:page controller=”Pagination_min”> <apex:form > <apex:pageBlock id=”pb”> <apex:pageBlockTable value=”{!Accounts}” var=”a”> <apex:column value=”{!a.Name}”/> <apex:column value=”{!a.Type}”/> <apex:column value=”{!a.BillingCity}”/> <apex:column value=”{!a.BillingState}”/> <apex:column value=”{!a.BillingCountry}”/> </apex:pageBlockTable> <apex:panelGrid columns=”7″> <apex:commandButton status=”fetchStatus” reRender=”pb” value=”|< First” action=”{!setCon.first}” disabled=”{!!setCon.hasPrevious}” title=”First Page”/> <apex:commandButton status=”fetchStatus” reRender=”pb” value=”< Previous” action=”{!setCon.previous}” disabled=”{!!setCon.hasPrevious}” title=”Previous Page”/> <apex:commandButton status=”fetchStatus” reRender=”pb” value=”Next >” action=”{!setCon.next}” disabled=”{!!setCon.hasNext}” title=”Next Page”/> <apex:commandButton status=”fetchStatus” reRender=”pb” value=”Last >|” action=”{!setCon.last}” […]

Ajax wild card search

<apex:page controller=”AjaxWildcardController”> <apex:form > <apex:pageBlock > Type Account Name Here :<apex:inputText value=”{!inputtext}” > <apex:actionSupport action=”{!actionSupMethod}” event=”onkeyup” reRender=”outptText” /> </apex:inputtext> </apex:pageBlock> <apex:pageblock > <apex:pageblocktable value=”{!accList}” var=”acc” id=”outptText”> <apex:column value=”{!acc.name}”/> <apex:column value=”{!acc.accountnumber}”/> </apex:pageblocktable> </apex:pageblock> </apex:form> </apex:page> public class AjaxWildcardController { public string inputtext{get;set;} public List<account> accList{get;set;} public boolean flagshow{get;set;} public AjaxWildcardController(){ flagshow = false; } Public void […]

apex:page readOnly=true

If you choose to use the to render your table you are normally limited to 1000 items in the collection that it iterates over. If you set the readOnly attribute on the

Considerations When Using OFFSET

I have just learned that maximum offset is 2,000 rows according to the documentation below: http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_offset.htm Which is annoying, since the standard query can return up to 50k records. Which means that you can hit the offset as soon as the 20th page (on a 100/page configuration) by using datatable. Just keep in mind