Salesforce Certificate

Friday, 17 January 2014

Add years in salesforce standard & custom date field on Visualforce Page

In salesforce calender widget we can't able to select previous years from UI. but sometimes in business it's very important to select that.

Add below Javascript code in your visualforce page to add years in salesforce standard & custom date field

Javascript:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<span id="hideThisHomePageComp"></span>
  <script type="text/javascript">
  $j = jQuery.noConflict();
   $j(document).ready(function() {                   var startYear=1900;                   var endYear=2024;                   var htmlStr='';                  if(startYear<endYear){
                                 for(i=startYear;i<endYear+1;i++){
                                                 htmlStr += "<option value=\""+i+"\">"+i+"</option>";
                                 }
                                 $j('#calYearPicker').html(htmlStr);
                  }
   $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();
                  }  );
  </script>
 so your visualforce Page will be look like this.

Visualforce Page:
<apex:page standardController="Contact" id="mypage">
  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<span id="hideThisHomePageComp"></span>
  <script type="text/javascript">
  $j = jQuery.noConflict();
   $j(document).ready(function() {                   var startYear=1900;                   var endYear=2024;                   var htmlStr='';                  if(startYear<endYear){
                                 for(i=startYear;i<endYear+1;i++){
                                                 htmlStr += "<option value=\""+i+"\">"+i+"</option>";
                                 }
                                 $j('#calYearPicker').html(htmlStr);
                  }
   $j('#sidebarDiv #hideThisHomePageComp').parent().parent().hide();
                  }  );
  </script>

    <apex:form >  
        Date: <apex:inputField value="{!contact.birthdate}" id="demo" onfocus="DatePicker.pickDate(false, this , false);"/>  
    </apex:form>
</apex:page>


Wednesday, 15 January 2014

Enable inline editing after Overriding Standard Buttons of Salesforce Object

Whenever we override Standard Buttons ("EditDelete") of any object in sales force then inline editing of that object records has been removed. we can't able to do inline Editing from view page of that particular object record.

Solution:
To Enable inline editing layouts, we have to do the following steps.

Step 1:
Create one custom visualforce page with following code.

<apex:page id="CaseDetail" StandardController="YoursObjectAPIName" 
tabStyle="YoursObjectAPIName" sidebar="true" >
    <apex:detail inlineEdit="true" relatedList="true"/>
</apex:page>

Note: In above code you have to Put API name of your Salesforce object.

Step 2:
Override your Standard button of Object("View") with custom visualforce page which we have developed in above step.

Tuesday, 14 January 2014

Use calendar widget without Current date link In Visualforce Page


Add following CSS Stylesheet in visualforce page to remove Current date link from input field.

CSS Stylesheet:
<style>
        span.dateInput span.dateFormat{
        display:none;
    }
</style>