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