Thursday, 10 November 2011

WSDL Structure

Salesforce Webservice API is implemented to comply with the following standards

Simple Object Access Protocol (SOAP) 1.1
Web Service Description Language (WSDL) 1.1
WS-I Basic Profile 1.1

WSDL 1.1 (Web Service Definition Language) Documents

WSDL doc describes the web service definition language and it has the following major components.

<type> -> data type
<message>  -> messages
<portype>  -> the operation performed by the web service
<binding> -> communication protocols used by the web service.

Sample wsdl document:
<definition>
<message name="getInputRequest">
  <part name="term" type="xs:integer"/>
  <part name="term" type="xs:integer"/>
</message>

<message name="getResultResponse">
  <part name="value" type="xs:integer"/>
</message>

<portType name="calculate">
  <operation name="add">
    <input message="getInputRequest"/>
    <output message="getResultResponse"/>
  </operation>
</portType>

<binding type="calculate" name="b1">
   <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
   <operation>
     <soap:operation soapAction="http://example.com/calculate"/>
     <input><soap:body use="literal"/></input>
     <output><soap:body use="literal"/></output>
  </operation>
</binding>
</definition>

where

  • types, which provides data type definitions used to describe the messages exchanged.
  • message, which represents an abstract definition of the data being transmitted. A message consists of logical parts, each of which is associated with a definition within some type system.
  • portType, which is a set of abstract operations. Each operation refers to an input message and output messages.
  • binding, which specifies concrete protocol and data format specifications for the operations and messages defined by a particular portType
Wsdl 1.1 vs 2.0

Tuesday, 8 November 2011

Salesforce Certification - Mock Exam

Salesforce Certification  - Mock Exam - Sample Question & Answers

Salesforce Training

* Salesforce Training videos are available here: DEV401, DEV501, Admin course videos are available here.
http://salesforcechannel.com/pages/developer-training

* Dreamforce & other webinars are available:
http://salesforcechannel.com/

* Salesforce training videos are also available in iTunes
http://itunes.apple.com/gb/podcast/salesforce.com-training-certification/id325668840#

* How to deploy the salesforce database:
http://www.youtube.com/watch?v=4K1RnpSMieQ

Use http://www.database.com to create your free (30 day trail) development sandbox & practice yourself the deployment operation.

* Understanding Security concepts (Profiles, Roles, OWD, Sharing Roles, Groups, Manual Sharing).
http://www.youtube.com/watch?v=uc13wsQJzz0

Record Id

There are two versions of every record Id in salesforce :


15 digit case-sensitive version which is referenced in the UI
18 digit case-insensitive version which is referenced through the API



  • Each of the 15 characters can be a numeric digit (0-9), a lowercase letter (a-z), or an uppercase letter (A-Z).   Two unique IDs may only be different by a change in case.
  • Because there are applications like Access which do not recognize that 50130000000014c is a different ID from 50130000000014C, an 18-digit, case-safe version of the ID is returned by all API calls. 
  • The 18 character IDs have been formed by adding a suffix to each ID in the Force.com API. 18-character IDs can be safely compared for uniqueness by case-insensitive applications, and can be used in all API calls when creating, editing, or deleting data.   Salesforce.com recommends that you use the 18-character ID.
  • The last 3 digits of the 18 digit ID are all capital letters and each of those 3 is a checksum for the other digits in the 15 digit ID. The 16th digit is a checksum of the first 5 characters, the 17th checks the second 5, and the 18th checks the last 5.


Saturday, 5 November 2011

MVC Design Architecture

undefined


Controller:  Whenever the client/user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data (db), the controller is responsible for directing the appropriate view to the user. In  GUIs, the views and the controllers often work very closely together.


Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.  


View : The view represents the presentation of the application. The view object refers to the model/data. It uses the query methods of the model/data to obtain the contents and renders it.


In Salesforce:
Model refers Objects/fields
View refers VF Pages/CSS
Controller refers VF Controller/Apex Code


Trigger Context Variable: Trigger.new vs Trigger.old

Trigger.new stores new values of a record. This basically means that when you edit a record and save it, your trigger would be called and the values that you have changed will be available in Trigger.new.

  • Returns a list of the new versions of the sObject records.
  • Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.

Trigger.old stores the old values of a record. This basically means that when you edit a record and save it, your trigger would be called and the values that were available before you edited the record would be stored in Trigger.old.

  • Returns a list of the old versions of the sObject records.
  • Note that this sObject list is only available in update and delete triggers.
Context Variable Considerations
  • trigger.new and trigger.old cannot be used in Apex DML operations.
  • You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved, so a runtime exception is thrown.
  • trigger.old is always read-only.
  • You cannot delete trigger.new.


Salesforce.com Competitors

How 3 Salesforce.com Competitors Are Trying to Poach Customers at Dreamforce

  • Microsoft Dynamics
  • Oracle CRM On Demand
    • With CRM On Demand you can do all this and a lot more, leveraging a market-leading, flexible hosted CRM solution offered at a predictable per user, per month price.

      With comprehensive features that include:
      • Sales: tools for driving pipeline and forecasting effectiveness
      • Service: tools for resolving issues efficiently across all customer touch points
      • Marketing: tools for managing, executing and analysing effective campaigns
      • Call Centre: tools for delivering a hosted multichannel support application in days
      • CRM Analytics: tools for combining real-time intelligence with deep historical knowledge
      • Mobile: tools for 'anytime, anywhere' access to key customer information
  • Sugar CRM
    • Sugar is affordable and easy to use business CRM, designed to help your business communicate with prospects, share sales information, close deals and keep customers happy. Thousands of successful companies use Sugar everyday to manage sales, marketing and support.
    • As an open-source, web-based CRM solution, Sugar is easy to customize and adapt to your changing needs. Ideal for small and medium-sized companies, large enterprises and government organizations, Sugar can run in the Cloud or on-site.

Friday, 4 November 2011

LookUp vs Master - Detail relationship in SFDC

Master – Detail Relationship :
  1. We cannot create master – detail relationship type fields directly if records already exists.
  2. If we delete master records then detail (Child) records are deleted.
  3. The Owner field on the detail and subdetail records is not available and is automatically set to the owner of the master record. Custom objects on the “detail” side of a master-detail relationship can't have sharing rules, manual sharing, or queues, as these require the Owner field.
  4. You can define master-detail relationships between custom objects or between a custom object and a standard object. However, the standard object cannot be on the detail side of a relationship with a custom object. In addition, you cannot create a master-detail relationship in which the User or Lead objects are the master.
  5. The master-detail relationship field is required on the page layout of the detail record.
  6. Rollup Summary fields are only available on master-detail relationships, not lookups.
  7. One detail side record can have maximum 2 masters but no limit on the Lookup fields.
Look up relationship :
  1. Look up relationship creates relations between two objects.
  2. If we delete any object then other object is not deleted.

Thursday, 3 November 2011

How to create Web-To-Lead ?

1. To create a Web-to-Lead form, click Click Your Name | Setup | Customize | Leads | Web-to-Lead.

2. Select fields to include on your Web-to-Lead form.

3. Specify the complete URL to which users should be directed after they submit their information—for example, your company's home page for a thank you page—and click Generate.

4. Copy the generated HTML code and provide it to your company's webmaster to incorporate into your website.
    (or)  save the copied html code into your local drive eg. c:\salesforce\WebToLeadExample.html

5. Click Finished.

6. Double click the WebToLeadExample.html file saved in step 4 and enter the details and click "Submit"

7. Click the Leads tab in your Salesforce application and check the newly created web to lead details.

Sunday, 30 October 2011

Bulikfy Apex Code / Trigger


Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.  If a batch of records (via the webservices call) invokes the same Apex code, all of those records need to be processed as a bulk, in order to write scalable code and avoid hitting governor limits.
eg.
trigger accountTestTrggr on Account (before insert, before update) {

   List<String> accountNames = new List<String>() {
 
   //Loop through all records in the Trigger.new collection
   for(Account a: Trigger.new){
      //Concatenate the Name and billingState into the Description field
      a.Description = a.Name + ':' + a.BillingState
   }
   
}

Dynamic Visualforce bindings

Dynamic Visualforce binding is useful to write generic Visualforce pages that display information about records without knowing which fields to show. In other words, fields on the page are determined at runtime, rather than compile time.

To create a new field set:


Navigate to the field set list of the appropriate object:
    • For standard objects, click Your Name | Setup | Customize, select the appropriate object from the Customize menu, and click Field Sets.
    • For custom objects, click Your Name | Setup | Create | Objects, and select one of the custom objects in the list. Then click New above the field sets related list.


eg.
<apex:page standardController="Contact">

    <apex:form >
        <apex:repeat value="{!$ObjectType.Contact.FieldSets.Demo_Field_Set}" var="f">
            <apex:InputText value="{!Contact[f]}" /><br/>
        </apex:repeat>
    </apex:form>
</apex:page>

Salesforce Security

Security in Salesforce is defined at multiple levels and these levels are -
  1. Security at object level (Profile)
  2. Security at field level (Profile)
  3. Security at record level
    1. Organization-wide defaults
    2. Role-hierarchy
    3. Sharing rules
    4. Manual Sharing



Profile: Object & field level security can be setup via profile and CRUD permissions can be set for standard & custom objects.

OWD: Used to restrict the permission.,  

All profiles get at least the privileges defined in OWD. OWD takes three different values -
  1. Private (Cant view and edit)
  2. Public Read only (Can view)
  3. Public Read-Write (Can view and edit)
Manual Sharing:
Manual Sharing is used to grant one-off access. Manual sharing can be granted by record owner, any one above the owner in role hierarchy and System Administrator. Manual sharing is used to handle exception cases where access to a particular record needs to be given to a specific user. There is a Sharing button on the records page. This is used to provide manual sharing. 

Role Hierarchy:
Role Hierarchy allows additional users access to records.    If the role has access to some records, then it's parents and ancestors are able to access the record as well.

Sharing Rules:
Share between roles in diff. hierarchy branches.    Sharing rule is defined using public groups. Record that match certain condition can be assigned to users in public groups using Sharing Rules. Sharing rules functionality is available via the menu Sharing Settings.

How to compare date in Dynamic SOQL

First convert the date value into datetime value, because format method can't used with the Date Type.
Date orig = customPage.startDate;


DateTime dtConverted = Datetime.newInstance(orig.year(),orig.month(),orig.day(),0,0,0);
       
System.debug(' converted date ' + dtConverted.format('yyyy-MM-dd\'T\'h h:mm:ss\'Z\'');




String qry = 'Select id, name, CreatedDate from Account ' +
        'where createddate > ' +  dtConverted.format('yyyy-MM-dd\'T\'h h:mm:ss\'Z\'') + ' order by name ';


List<Account> searchResults = Database.query(qry);

Saturday, 29 October 2011

Find Day of the week in Salesforce

Any of the following date formats can be used to calculate the day of the week .


String shortDayOfweek = DateTime.now().format(‘EEE’); // ‘Sat’
String longDayOfweek = DateTime.now().format(‘EEEEE’); // ‘Saturday’

How to Create a Visualforce page

* Salesforce application is easy to develop

* You can register a 30 day free development environment & start developing your first helloworld application
      http://developer.force.com/

* First enable the Development mode
     i) Click Setup
     ii) From Personal Setup ->
                  Click My Personal Information -> Personal Information
                 
                  Enable the "Development Mode" checkbox

* You can create the visualforce page by entering the url as the following  (by appending /apex/helloword to the salesforce url).
              https://na12.salesforce.com/apex/helloword

* Since this page is not exists, system will display the message to create the page

* Click the click to create the page

* The helloworld page will be created and the visual force code will be displayed in the programming pane.

You can modify the code as the following and the see the result.   It's so simple.

<apex:page>
    <h1> My first Hello World Program </h1>
<apex:page>