Skip to main content

Posts

Searching Component In SFDC

Hi All, This is a  cool post for me.Here I have created one page where you can search many sfdc component(apex class,vf pages, user,report,approval process, trigger).  Useful for Whom ? All developers who always try to finish work as son as possible. Don't want click on Next & Prev link to reach at particular component(if more than 100 is there). Want to get all different component in one page. The best thing is with in less time to get component. We can search these component as below image.if you want to search more than add that component in options list rest will be take care. Here is the Page:- <apex:page controller="SearchApexComponent">     <apex:form >                  <apex:pageBlock title="Find Your SFDC Component" id="pblock">         <apex:pageMessages id="message"></apex:pageMessages>          <apex:outp...

Filtering Record Using Long Text Area Field

Hi All, We might have come across a scenario to filter some record based on a field value which is long text area type.This is post is all about how can we filter records using text area field value. Here is code:- String s; list<Account> listOfAccounts = [SELECT id,name FROM Account WHERE TextAreaFiedl__c like :'%'+s+'%']; If we write same code then compiler will fire a error like below image. Below is work around for above error. String s = 'asish'; list<Account> listOfAccounts;  listOfAccounts = new list<Account>(); for(Account acc:[SELECT id,name,TextAreaFiedl__c FROM Account where name='test']){     if(acc.TextAreaFiedl__c.Contains(s)){        listOfAccounts.add(acc);     } }

How would we get recordtype id and recordtype name of an particular Object?

Hi All, Sometimes it may require to know the recordtypeid and recordtypename of an object in apex class.This is post is all about to make you comfortable with Recordtype methods.I am assuming you have concept of recordtype. Below is few code snippet to make you comfortable with recordtype method. RecordTypeInfo is a class contains methods for accessing recordtype information for an sObject with associated recordtype. getRecordTypeInfosByName(); - Returns maps that associate RecordTypeInfo with  record labels. getRecordTypeInfosById();- Returns maps that associate RecordTypeInfo with  record Id. getname():- Returns recordtype name. getRecordTypeId() :- Returns recordtype id. isAvailable() :-Returns true if this record type is available to the current user, false otherwise isDefaultRecordTypeMapping() :-Returns true if this is the default record type mapping, false otherwise. Here Contact is the standard object and Service Contact is the recordtype name. Sch...

Displaying a picklist in Mulit Select Checkbox format in Salesforce

Hi All, Generally we provide flexibility to user so that user can select multiple value form a picklist at a time. This post is only for displaying a pick-list in multi select check-box format.   Here is the page:- <apex:page controller="multiselectCheckboxController ">     <style>     input[type='checkbox'] {         border: 1px solid #aaa;         display: block;     }     </style>    <apex:form>          <apex:pageBlock>         <apex:pageBlockSection columns="1">             <apex:pageblocksectionitem >                           <apex:outputlabel value="Industory" />                 <apex:selectcheckboxes layout="pageDirection" value="{!Industo...

How to get help text in apex class ??

We generally use help text while creating custom field in salesforce . Sometimes we need it in apex controller while development. This post is regarding to get help text of particular field and display in vf page.  Here is some code snippet to get help text in apex class. Schema.DescribeFieldResult dfr = Schema.sObjectType.Account.fields.TestField__c; String helptext = dfr.getSObjectField().getDescribe().getInlineHelpText(); In the visualforce page we can display help text. {!$ObjectType.Account.fields.TestField__c.inlineHelpText}

How to check list size in Visualforce page

Hi All, It seems to very simple by name but not as much simple as you are thinking now.As we all know list itself has a method so called size() to check its size,however we can write list.size() in controller, which will return no. of elements present in the list otherwise return 0 if no elements present .But we can not write list.size method in visual-force page,then how will we check ???? For that I have done a workaround, one visual-force page is there having one field Account Type. When Account Type will be selected with some value ,then list of Accounts records will be displayed whose Account Type is matched with the selected value otherwise a message saying No Accounts Present in this Type. Here is page:- <apex:page controller="passingParamActionFuncController">     <apex:form >         <apex:pageBlock title="Account Information" id="pb">             <apex:pageBlockSection >   ...

How to do DML Operation when a Page loads

Hi All, Here is a scenario that I have come across, there was a need to do DML operation when a vf page loads. How will we achieve it ? As we all know when a page loads, constructor executes first but we can not write DML statement in constructor,however there is another approach for the above requirement.  Here is the Page.  <apex:page controller="DMLStatementOnPageloadController" action="{!createAccount}" > </apex:page> createAccount will be invoked when page loads. Controller:- public with sharing class DMLStatementOnPageloadController {     public PageReference createAccount(){         Account acc = new Account(name = 'DMLStatementOnPageload');         insert acc ;         return null;     } }