Another Salesforce blog!!!

Salesforce, Apex

July, 2016

SALESFORCE icons available Favorite

How to user apex:stylesheet in visualforce page?

Step 1: Create a CSS file. Save the file with a .css extension Step 2: Upload the saved file as a Static resource. Have reference in VFP like this: <apex:stylesheet value=”{!$Resource.CssExample}”/> Another way of referencing is: <apex:stylesheet value=”{!URLFOR($Resource.myofferZIP, ‘myofferCSS.css’)}”/> Favorite

String is null or empty or blank using Apex in Salesforce

To check whether a String is null or empty or blank using Apex in Salesforce, we can use the following methods isBlank Returns true if the specified String is white space, empty (”), or null; otherwise, returns false. isEmpty Returns true if the specified String is empty (”) or null; otherwise, returns false. isNotBlank Returns […]


Here are some examples of how to add messages with different severities and how they are outputted: VFP: <apex:pageMessages /> APEX Controller: Confirm/Success: ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Confirm,’Sample Success Message’)); Warning: ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Warning,’Sample Warning Message’)); Informational: ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Info,’Sample Informational Message’)); Error: ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.Error,’Sample Error Message’)); Favorite

Remove –None– from Salesforce Picklist

<apex:page standardController=”Lead”> <apex:form> <script type=’text/javascript’ src= ‘//’> </script> <script language=”javascript”> $(function() { $(‘select.RemoveNone option[value=]’).remove(); }); </script> <apex:inputField styleClass=”RemoveNone” value=”{!Lead.LeadSource}”/> </apex:form> </apex:page> Favorite

Managing Matching/Duplicates Rules

How to detect the duplicate records using Duplicate Management: Step 1: MATCHING RULES: Setup–> Administration –>Duplicate Management –>Matching Rules (Click) –>New –>Select the object –> Rule Name: “Unique Name matching rule” (of whatever it suites your needs) –> Field: Name –> Matching Method: Exact –>Save/Activate Step 2: DUPLICATE RULES: Setup–> Administration –>Duplicate Management […]

Visualforce page Search: InputText with Button

Visualforce page: <apex:page standardcontroller=”Offer__c” extensions=”OfferPreviewExtController” title=”Offer – {!Offer__c.Name}” sidebar=”false” showHeader=”false”> <!– Page Header –> <!–apex:sectionHeader title=”Candidate Edit” subtitle=”New Candidate” /–> <br/> <apex:image style=”padding:5px;” value=”” styleClass=”logo” /> <!– Begin Form –> <br/> <style type=”text/css”> .bg { color:white !important; background:#00CC00 !important; } </style> <apex:form > <apex:pageBlock > <center> <apex:outputLabel value=”Offer ID: ” style=”font-size:22px;”></apex:outputLabel> <apex:inputText value=”{!searchText}” id=”theSearchstring” styleClass=”increaseSize” […]

Visualforce page with two columns

<apex:pageBlockSection> <apex:repeat value=”{!accounts}” var=”acc”> <apex:pageBlockSection> <apex:outputLink value=”{!URLFOR($Action.Account.Edit,, [retURL=URLENCODE(‘/apex/RetUrlSearchPage?query=’+nameQuery)}”> {!acc.Name} </apex:outputLink> </apex:pageBlockSection> <apex:pageBlockSection> <apex:outputField value=”{!acc.BillingStreet}” /> </apex:pageBlockSection> </apex:repeat> </apex:pageBlockSection> Favorite

Salesforce – Making the User Object standard field Unique.

PS: make sure to add <apex:pageMessages id=”pageMsg”/> on the VFP trigger ExtesionTrigger on User (before insert , before update) { Set<String> setExtension = new Set<String>(); for(User u : { Boolean isNewExt = setExtension.add(u.Extension); //This will ensure that in bulk insert you are not inserting two users with same extension if(!isNewExt) u.addError(‘Dulicate Extension’); } List<User> […]

Salesforce – How to determine the value is unique

At first let us create a new Field on the custom object/standard object. 1. Go to Setup | Customize | Accounts | Fields. 2. Scroll down to Custom Fields & Relationships Section. 3. Click New Field. 4. Select the Type as: Text 5. Name it as: Account Name Dupe Check[Field_Name_Dupe_Check, 255]. 6. Check the Option: […]

Previous Posts