Posts

Showing posts from 2016

How to Query all fields in Apex ( SELECT (ALL) * FROM SObject )

Hello Guys, We have situations where we need to query all fields from any SObject in salesforce and because in SOQL we have to maintain resource allocation therefore we don't have option such as to query like SELECT * FROM SObjectName like we used to have in SQL. So here is the utility method that you can use to fetch all field names for a particular SObject and return as string: Method:   public static String fetchFieldNames(String sObjectName){       String SobjectApiName = sObjectName;       Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();       Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();       String commaSepratedFields = '';       for(String fieldName : fieldMap.keyset()){           if(commaSepratedFields == null || commaSepratedFields == ''){               commaSepratedFields = fieldName;           }else{               commaSepratedFields = commaSe

Utiity method to get week number of month by passing a Datetime value

Hi Techies, Here below is the Method that you can use in order to fetch week number in a month: for ex: Pass                ->     Result .......................................... 1July2016                 1 8July2016                 2 22July2016               4 and so on.... Method :     public Integer weekOfMonth( Datetime dateVar){                 Date currentDate = dateVar.Date();                 Integer weekCount = 0;                 Integer startWeekResidue = 0;                 Integer endWeekResidue = 0;                 //Calculating startWeekResidue                 Date dt = currentDate.toStartOfMonth().addDays(-1);                 Date dtFirstWeekend = dt.toStartOfWeek().addDays(6);                 startWeekResidue = dt.daysBetween(dtFirstWeekend);                 //Calculating endWeekResidue                 Date dtLastWeekend = currentDate.toStartOfWeek().addDays(-1);                 endWeekResidue = dtLastWeekend.daysBetween(currentDate);    

Include Lightning Component in Visualforce Page

Yes, it's possible now. We can put our Lightning Component inside Visualforce page, it would help us to combine features we have built using both VF and Lightning Component. Basically we have four steps to add lightning component to a Visualforce Page. Step 1: a) Create simple lightning aura application and make it global and extend ltng:outApp , now save this app as "MyLightningApp" <aura:application access="GLOBAL" extends="ltng:outApp"> b) Create a component and save it as "MyLightningCmp". <aura: component> Test - We are inside component now!! </aura:component> Step 2: Add a dependency to our application, The app uses the <aura:dependency> tag to indicate that it uses the standard Lightning component, such as ui:button and Custom Component in our case "MyLightningApp" Note: If the app is defined in your org (that is, not in a managed package), you can use the

Generic Component for Loading Icon on Visualforce Pages

Image
While developing a Solution using Visualforce page and Apex, we have one common requirement which is to  show loading icon  whenever user click on button/link/panel etc. Few use case to show loading icon could be:       1.    Notify user that action he asked for is in progress. 2.    Don't want user to make any change till previous action finishes. The following is the screenshot of how Loading icon would show: To achieve this, we will create a new VF Component ( Go to Setup -> Develop -> Component -> New. Name= “LoadingIcon” ) The Icon that we will be using here is standard Icon provided by salesforce, therefore no need to upload any static resource. Visualforce Component: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 <apex:component > <apex:actionStatus onstart=

Use of isdtp parameter in URL in Salesforce (Hide header and Sidebar)

Hi Guys, If we want to hide header for VF what do you do, very simple, you just specify the showheader="false". Similarly if want to hide Sidebar and chat widget from VF, we specify sidebar=”false” and showChat=”false” respectively. These are simple attributes we use in Page tab to hide header, sidebar and chat widget. Ex: <apex:page showHeader=”false” sidebar=”false” showChat=”false”> But suppose you want to display a report on your VF, and you don't want the header and sidebar to appear, Or what if in case you want to display Iframe and don’t want header,sidebar in that Page. isdtp comes in picture, so we can say that main purpose of isdtp can be used to hide SFDC header and sidebar on Standard Pages This will work after added the parameter in standard salesforce pages by using the url parameter:  isdtp=mn  or  lt or vw or nv vw  – The VF page will be rendered without header and sidebar, supports aloha theme, allows chatter lt  

Javascript Function for Validation on Input fields ( Useful for Number,Letters,Characters,Currency validations)

Hi Guys, Many a times we have requirement where we need to have validation on Input field to let user enter  just number, just letters or related to currency etc. Below you can find a single javascript function to handle all situation related to numbers, characters, currency, specialCharacters. Javascript code:    <script type="text/javascript">     // This function is being used for providing different validation on your text box as per your need     function inputLimiter(e,allow) {             var AllowableCharacters = '';             if (allow == 'Letters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';}             if (allow == 'Numbers'){AllowableCharacters='1234567890';}             if (allow == 'NameCharacters'){AllowableCharacters=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\'';}             if (allow == 'NameCharactersAndNumbers'){Allowa