Salesforce Certificate

Thursday, 19 February 2015

New Features in Mobile SDK 3.1




SmartSync Library Feature (Unified SmartSync API for native and hybrid apps)


With the use of Unified SmartSync Framework we can easily store the data locally using the Cordova’s smartSync plugins and APIS. With the use of following two methods.this will provide us the ability to store objects locally and sync them to the cloud.
  1. syncUp()
  2. syncDown()

Authentication Feature

Salesforce Mobile SDK 3.1 have flows to initiate authentication with an enterprise certificate.

Note: The above features are supported only in iOS7+ and Android Lollipop (API 21) and above.


CocoaPods for iOS

Now, we have the ability to consume the Salesforce Mobile SDK through CocoaPods, which makes dependency management a chore of the past. It’s now easier than ever before to insert Salesforce Mobile SDK modules into an existing app or evolve a new app with other third party libraries.

Gradle for Native Android Apps :

Android Studio and the Gradle build system are now fully supported for native apps. Gradle support for hybrid apps will arrive after the next Cordova update.

GitHub Repos


Android: https://github.com/forcedotcom/SalesforceMobileSDK-Android/tree/master/native/SampleApps/SmartSyncExplorer

Hybrid App : https://developer.salesforce.com/blogs/engineering/2014/11/cross-platform-apps-salesforce-mobile-sdk-web-components.html

Reference Links:



https://developer.salesforce.com/blogs/engineering/2015/02/salesforce-mobile-sdk-3-1-unified-app-architecture-brings-unparalleled-flexibility.html

https://developer.salesforce.com/page/Building_Native_iOS_Apps_With_the_Salesforce_Mobile_SDK_3.1


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>

Friday, 12 July 2013

Conditionally Override "New" (Salesforce Standard button) as per Record Type Selection

Override "New" (Salesforce Standard button) as per RecordType Selection

Following is the snippet of anonymous code which will help you to override Salesforce standard "New" button as per RecordType selected by user.

Here is the example for Overriding standard "New" button of Account Object(Any sObject) as per RecordType Selection.

Step 1:
Override your Standard button of Account Object("New") with custom visualforce page to which you want to redirect page.

Step 2:
Create one Custom Label with Name = "Custom_page_rectype". Put here your custom recordtype value (hard coded) For which you want to override conditionally.

Step 3:
Put action attribute in your visualforce page's <apex:page> tag as below.

Visualforce Page:
<apex:page standardController="Account" extensions="extCtrlRecordtyperedirect"
action="{!if(strRecTypeName==$Label.Custom_page_rectype,null,
URLFOR($Action.Account.Edit,
$ObjectType.Account,null,true))}">

This is Your custom visualforce Page

</apex:page>

Apex Class: 
public class extCtrlRecordtyperedirect{ 
     Public string strRecTypeName {get; set; }
     public extCtrlRecordtyperedirect(ApexPages.StandardController controller) {
          strRecTypeid = apexpages.currentpage().getparameters().get('RecordType');
          if(strRecTypeid !=  null){
            Schema.DescribeSObjectResult d = Schema.SObjectType.Account;
            Map<Id,Schema.RecordTypeInfo> rtMapById = d.getRecordTypeInfosById();
            strRecTypeName = rtMapById.get(strRecTypeid).getName();
        }
}

Schedule Apex to run Every 24 HOUR


Schedule Class To - Run at Every 24 HOUR Everyday..

Following is the snippet of anonymous code which will help you to schedule your apex Job to run Every HOUR.

Write below code in "Developer Console" to schedule class for every One Hour Everyday.


Apex Code:
ScheduleclassEveryhour objschclass = new ScheduleclassEveryhour ();
string strSeconds = '0';
string strMinutes = '0';
string strHours = '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23';

string strDay_of_month = '*';
string strMonth = '*';
string strDay_of_week = '?';

String sch = strSeconds + ' ' + strMinutes + ' ' + strHours + ' ' + strDay_of_month + ' ' + strMonth + ' ' + strDay_of_week;
system.schedule('ScheduleclassEveryhour', sch, objschclass);

Wednesday, 17 April 2013

Display sObject Fields list in picklist of visualforce page without using controller



If you want to display picklist with any sObject field list in your visualforce page. you can do it using javascript without using Apex controller. No need to write class.

Here is the example for displaying all the field of Account in picklist.
Visualforce Page:
<apex:page>
    <apex:includeScript value="/soap/ajax/16.0/connection.js"/>
    <label id="ldfield" style="font-weight:bold">Account Fields: </label>
    <select id="selectNumber">
    </select>
     <script>
        sforce.connection.sessionId = '{!$Api.Session_ID}';
        //Global Object
        var describeResults = sforce.connection.describeSObject("Account");
        //select option list
        var select = document.getElementById("selectNumber");
        for(var i = 0; i < describeResults.fields.length; i++) {
            var fieldList = describeResults.fields[i];     
            var el = document.createElement("option");
            el.textContent = fieldList.label;
            el.value = fieldList.Name;
            select.appendChild(el);       
        }
    </script>
</apex:page>