Ads

Sunday 26 May 2013

Difference between SOAP and Restful Webservice?

* REST and SOAP are the two web service frameworks available on the Force.com platform. 
* The SOAP API uses authentication with username and password, and communicates using XML messages. There are different API's to work with the Enterprise, Partner, Bulk, Metadata etc. 
*The REST API uses HTTP to authenticate, it uses a token authentication and can use OATH to authenticate, it communicates using JSON messages. 
*REST API is generally lighter weight than the SOAP API, works well with mobile applications especially.


how to lock a record?

To lock a set of sObject records in Apex, embed the keywords FOR UPDATE after any inline SOQL statement

To display all the fields of sObject using Apex & VF?

<apex:page showHeader="false" Controller="FieldsClass">
        <apex:DataTable value="{!data}" var="d">
             <apex:column headerValue="Field Name">
                 {!d}
             </apex:column>         
         </apex:DataTable>
</apex:page>
*******************************
public class  FieldsClass {

     public map<string,Schema.SObjectField> data {get;set;}
  
     public  FieldsClass (){
         data = Schema.SObjectType.Book__c.fields.getMap();
        }
    }

We have three country buttons, if we click any button that country information should only display?

Apex:
public class coun {

    public Boolean hide = false;
    public Boolean hide1 = false;
    public Boolean hide2 = false;
    
    public void setMhide(Boolean b) {
    this.hide = b;
    }
    
    public Boolean getMhide() {
    return this.hide;
    }//Passing input dynamically through another method
    
    
    public Boolean getM1hide() {
        return this.hide2;
    }
    
    public void setM1hide(Boolean b) {
      this.hide2 = b;  
    }
    
    
    public Boolean getM2hide() {
        return this.hide1;
    }
    
    public void setM2hide(Boolean b) {
        this.hide1 = b;
    }
    
    
    public PageReference india() {
        setMhide(true);
        setM2hide(false);
        setM1hide(false);     
        return null;
    }//displaying only india information and hiding other information
    
     public PageReference us() {
        setM1hide(true);
        setM2hide(false);
        setMhide(false);
        return null;
    }
    
    public PageReference uk() {
        setM2hide(true);
        setM1hide(false);
        setMhide(false);
        return null;
    }   
    
}
Vf Page:
<apex:page controller="coun">
<apex:form >

<apex:commandButton value="India" action="{!india}" reRender="India,Us,Uk"/>
<apex:commandButton value="Us" action="{!us}" reRender="India,Us,Uk"/>
<apex:commandButton value="Uk" action="{!uk}" reRender="India,Us,Uk"/>

<apex:pageBlock >

<apex:outputPanel id="India">
<apex:pageBlockSection title="India" rendered="{!mhide}">
</apex:pageBlockSection>
</apex:outputPanel>
<apex:outputpanel id="Us">
<apex:pageBlockSection title="US" rendered="{!m1hide}">
</apex:pageBlockSection>
</apex:outputpanel>

<apex:outputpanel id="Uk">
<apex:pageBlockSection title="UK" rendered="{!m2hide}">
</apex:pageBlockSection>
</apex:outputpanel>

</apex:pageBlock>

</apex:form>
</apex:page>



Dispaly particular field based on the selection of the particular field?

<apex:page standardController="Book__c">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable id="mytable" value="{!Book__c}" var="item">
  <apex:column headerValue="Delivery">
    <apex:actionRegion >        
      <apex:inputField value="{!item.City__c}">
        <apex:actionSupport event="onchange" reRender="mytable"/>
      </apex:inputField>
    </apex:actionRegion>
  </apex:column>
  <apex:column headerValue="Delivery Type">
    <apex:inputField rendered="{!item.City__c = 'Chennai'}" value="{!item.Chennai__c}"/>
    <apex:inputField value="{!item.Banglore__c}"/>
  </apex:column>
</apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>


How To retrieve the records of the custom/standard object of the current user?

Solution:

Id aid = Userinfo.getUserId();
account ac = [Select Id, Name from Account Where CreatedById = : aid limit 1];
System.debug(' ---- ' + ac );

or

Id aid = Userinfo.getUserId();
List<Account> ac = [Select Id, Name From Account Where CreatedById = : aid Limit 10000];  


Report should be available only to CEO, for others it should be hide, how can we do it?

For a specific Report:
* Specific Report can be controlled by creating a custom report folder and assigning just the CEO as a viewer of this folder. All reports in the folder will be visible to the CEO only in that scenario.
* Observe below screen shots:




 For the Reports Tab:
* Reports Tab can be controlled by the User Profile

Saturday 25 May 2013

How to update record using SOQL?

Example:

Account act = [SELECT Id, Description__c FROM Account WHERE id = '001A000000vtDZo'];
act.Description__c = 'Fully product based account';

Update act;

Login Failed in Apex Dataloader?

Click Settings in Settings menu


 Don't forget to give your proxy host and proxy port
 

For Developer Edition, give password+security token as password. Username is as usual username.

How to start loading from the middle of the excel file in data loader?

1. Go to Settings in Apex Data Loader.


2. Set "Start at Row" field to start the process from the mentioned row number from the excel file.

Types of Reports in Salesforce?

Tabular

     Tabular reports are the simplest and fastest way to look at data. Similar to a spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed in a row. Tabular reports are best for creating lists of records or a list with a single grand total. They can't be used to create groups of data or charts, and can't be used in dashboards unless rows are limited. Examples include contact mailing lists and activity reports.

Summary

     Summary reports are similar to tabular reports, but also allow users to group rows of data, view subtotals, and create charts. They can be used as the source report for dashboard components. Use this type for a report to show subtotals based on the value of a particular field or when you want to create a hierarchical list, such as all opportunities for your team, subtotaled by Stage and Owner. Summary reports with no groupings show as tabular reports on the report run page.

Matrix

     Matrix reports are similar to summary reports but allow you to group and summarize data by both rows and columns. They can be used as the source report for dashboard components. Use this type for comparing related totals, especially if you have large amounts of data to summarize and you need to compare values in several different fields, or you want to look at data by date and by product, person, or geography. Matrix reports without at least one row and one column grouping show as summary reports on the report run page.

Joined

     Joined reports let you create multiple report blocks that provide different views of your data. Each block acts like a “sub-report,” with its own fields, columns, sorting, and filtering. A joined report can even contain data from different report types.

jQuery Syntax?

Basic syntax is: $(selector).action()
  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)
Examples:

$(this).hide() - hides the current element.
$("p").hide() - hides all <p> elements.
$(".test").hide() - hides all elements with class="test".
$("#test").hide() - hides the element with id="test".

Ready Event in jQuery?

Ready Event in jQuery is to prevent any jQuery code from running before the document is finished loading (is ready).

It is good practice to wait for the document to be fully loaded and ready, before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.

The handler passed to .ready() is guaranteed to be executed after the DOM is ready, so this is usually the best place to attach all other event handlers and run other jQuery code.

Events in jQuery?

$(document).ready()
The $(document).ready() method allows us to execute a function when the document is fully loaded.

click()
The function is executed when the user clicks on the HTML element.

dblclick()
The function is executed when the user double-clicks on the HTML element:

mouseenter()
The function is executed when the mouse pointer enters the HTML element:


mouseleave()
The mouseleave() method attaches an event handler function to an HTML element.
The function is executed when the mouse pointer leaves the HTML element:
  
mousedown()
The function is executed, when the left mouse button is pressed down, while the mouse is over the HTML element:
  
mouseup()
The function is executed, when the left mouse button is released, while the mouse is over the HTML element:


hover()
The first function is executed when the mouse enters the HTML element, and the second function is executed when the mouse leaves the HTML element.


focus()
The function is executed when the form field gets focus.


blur()
The function is executed when the form field loses focus.

jQuery Fading Methods?

jQuery has the following fade methods:

  • fadeIn()
  • fadeOut()
  • fadeToggle()
  • fadeTo()

jQuery fadeIn()

The jQuery fadeIn() method is used to fade in a hidden element.

Syntax:


$(selector).fadeIn(speed,callback);
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of a function to be executed after the fading completes.
The following example demonstrates the fadeIn() method with different parameters:


jQuery fadeOut()

The jQuery fadeOut() method is used to fade out a visible element.

Syntax:


$(selector).fadeOut(speed,callback);
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of a function to be executed after the fading completes.
The following example demonstrates the fadeOut() method with different parameters:


jQuery fadeToggle()

The jQuery fadeToggle() method toggles between the fadeIn() and fadeOut() methods.
If the elements are faded out, fadeToggle() will fade them in.
If the elements are faded in, fadeToggle() will fade them out. 

Syntax:


$(selector).fadeToggle(speed,callback);
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of a function to be executed after the fading completes.
The following example demonstrates the fadeToggle() method with different parameters:


jQuery fadeTo()

The jQuery fadeTo() method allows fading to a given opacity (value between 0 and 1).

Syntax:


$(selector).fadeTo(speed,opacity,callback);
The required speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The required opacity parameter in the fadeTo() method specifies fading to a given opacity (value between 0 and 1).
The optional callback parameter is the name of a function to be executed after the function completes.

jQuery Sliding Methods

jQuery Sliding Methods

With jQuery you can create a sliding effect on elements.
jQuery has the following slide methods:

  • slideDown()
  • slideUp()
  • slideToggle()

jQuery slideDown() Method

The jQuery slideDown() method is used to slide down an element.

Syntax:


$(selector).slideDown(speed,callback);
 
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of a function to be executed after the sliding completes.
The following example demonstrates the slideDown() method:

Example

$("#flip").click(function(){
  $("#panel").slideDown();
});

jQuery slideUp() Method

The jQuery slideUp() method is used to slide up an element.

Syntax:


$(selector).slideUp(speed,callback);
 
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or milliseconds.
The optional callback parameter is the name of a function to be executed after the sliding completes.
The following example demonstrates the slideUp() method:

Example

$("#flip").click(function(){
  $("#panel").slideUp();
});


jQuery slideToggle() Method

The jQuery slideToggle() method toggles between the slideDown() and slideUp() methods.
If the elements are slide down, slideToggle() will slide them up.
If the elements are slide up, slideToggle() will slide them down. 


$(selector).slideToggle(speed,callback);
 
The optional speed parameter can take the following values: "slow", "fast", milliseconds.
The optional callback parameter is the name of a function to be executed after the sliding completes.

The following example demonstrates the slideToggle() method:

Example

$("#flip").click(function(){
  $("#panel").slideToggle();
});