ads

Tuesday, 28 August 2018

SOAP API Methods using WSDL from Salesforce

1.) create()


2.) update()

3.) upsert()

4.) delete()

5.) merge()

6.) query()
To perform an initial query against a Salesforce Org.

7.) queryAll()
To perform a query against a Salesforce org that returns records in the Recycle Bin as well as active records.

8.) queryMore()
To get additional batch results from a query. Default batch size is 500. Minimum batch size is 200 and maximum batch size is 2000.

9.) retrieve()
To retrieve data from objects based on their ids.

Example:
retrieve("Id, Name, Website", "Accounts", ids)

10. emptyRecycleBin()

11. login()
Uses username and password to log in. Gets session id and URL to maintain the connection.

12. logout()

13. search()

14. getDeleted()
Retrieves deleted records for the specific time interval.

Example:
getDeleted("Account", StartTime, EndTime)

15. getUpdated()
Retrieves updated records for the specific time interval.

Example:
getUpdated("Account", StartTime, EndTime)

16.getUserInfo()

17.) resetPassword() 

18.) convertLead()

19.) process()

20.) getServerTimeStamp()

21. setPassword()

22. sendEmail()

23. sendEmailMessage()

24.) describeTabs()

25.) describeLayout()

26.) describeGlobal()

27.) describeSObjects()

28. describesoftphoneLayout()

To get current Path: ApexPages.currentPage().getUrl()

Code Format:


Visualforce page:
<apex:page controller="Path">
    <apex:form >
        <apex:pageBlock >
            Current URL is {!currURL}
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:
public with sharing class Path {
    
    public String currURL {get;set;}
    
    public Path() {
        currURL = ApexPages.currentPage().getUrl();
    }
        
}

Output:


Hide lines and borders in pageBlock tag in Visualforce Page

Code Format:

<apex:page standardController="Contact" sidebar="false">

 <style>

    .bPageBlock .pbBody .dataCol {

        border:0px;

    }

    .bPageBlock .pbBody .labelCol {

        border:0px;

    }

</style>

    <apex:form >

        <apex:pageBlock mode="maindetail">

            

                <apex:pageBlockSection columns="2"  >

                <apex:selectList value="{!Contact.Name}"/>

                <apex:inputField value="{!Contact.AssistantName}"/>

                <apex:inputField value="{!Contact.Birthdate}"/>

                <apex:inputField value="{!Contact.Department}"/>

                <apex:inputField value="{!Contact.LeadSource}"/>

                <apex:inputField value="{!Contact.Phone}"/>


            </apex:pageBlockSection>

            <apex:pageBlockButtons >

                <apex:commandButton value="Save" action="{!save}"/>

                <apex:commandButton value="Cancel" action="{!cancel}"/>

            </apex:pageBlockButtons>

        </apex:pageBlock>

    </apex:form>

</apex:page>


Output:


Monday, 27 August 2018

Command Buttons Align Right in Visualforce page

Code Format:

<apex:page showHeader="false" controller="example" >

<apex:form >
   <apex:panelGrid columns="1" style="float:right;">

        <apex:commandButton value="First"/>
        <apex:commandButton value="Second"/>
        <apex:commandButton value="Third"/>

        <apex:commandButton value="Done"/>
      
    </apex:panelGrid>

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



Output: 

Friday, 17 August 2018

write a validation rule of Multiselect Picklist in Salesforce

In this INCLUDES() is used to write a validation rule of Multiselect Picklist in Salesforce.

Determines if any value selected in a multi-select picklist field equals a text value you specify.

Syntax:

INCLUDES(Multipicklist_Api_Name, Text_Value)

Get Case Id from CaseComment object using trigger

Sample Code:

Trigger getParentCase on CaseComment(after insert) {

set<Id> CCIds = new set<Id>();

      
    
     for ( CaseComment c: trigger.new ) {
     CCIds.add(c.Id);
     }
    
     List < CaseComment > lCComment = [ SELECT Id, Parent.Id FROM CaseComment
                                                                                                                                          WHERE Id IN: CCIds];
    
   set<Id> CaseIds= new set<Id>();        
for ( CaseComment c: lCComment) {
        
CaseIds.add(c.Parent.Id); // collect case Id in set of Id

        }

}

update parent records when task created or updated

Sample Trigger:

trigger  TaskParentUpdate  on Task (after insert, after update) {

    Set < Id > setIds = new Set < Id >();


if(IsInsert || IsUpdate) {

    for ( Task tsk : trigger.New) {
        if ( tsk.WhatId.getSobjectType().getDescribe().Name == 'Accounts' )
        setIds.add(tsk.WhatId);
    }
   
}

    List<Account> lAccount = [Select Id,description From Account where Id IN:setIds];


  List<Account> UpdateAccount = new List<Account>();

    for(Account a:lAccount){
        a.description = 'Description Updated';
       UpdateAccount.add(a);

   }


  update UpdateAccount;


}

Help text for apex:inputField

Code Format:

Visualforce Page:

<apex:page controller="helpcontroller">
<apex:form >
        <apex:pageBlock >
           
                <apex:pageBlockSection >
                
                <apex:pageBlockSectionItem helpText="Owner of the Account">
                
                    Owner Name <apex:inputField value="{!acc.Name}"/>
                    
                </apex:pageBlockSectionItem>
               
                </apex:pageBlockSection>
            
        </apex:pageBlock>
</apex:form> 
</apex:page>


Apex Class:

public with sharing class helpcontroller{
       public Account acc{get;set;}
        public Sample() {
    }    
}

Ouput:

Check object level security within a Visualforce page


By using this " {!$ObjectType.Lead.Accessible} " to check object level security within a Visualforce page in Salesforce.

VF page Code Format:

<apex:page>

    {!$ObjectType.Lead.Accessible} 

</apex:page>

Visible required symbol in apex:inputText

Code Format:

VisualForce Page:

<apex:page controller="makeRequired">

    <apex:form >

        <apex:pageBlock >

                <apex:pageBlockSection >

                <apex:pageBlockSectionItem >

                   <apex:outputLabel value="Account Name"/>

                    <apex:outputPanel styleClass="requiredInput" layout="block" >

                    <apex:outputPanel styleClass="requiredBlock" layout="block"/>

                    <apex:inputText value="{!str}" required="true"/> 

                    </apex:outputpanel>

               </apex:pageBlockSectionItem>

                </apex:pageBlockSection>

        </apex:pageBlock>

    </apex:form>

</apex:page>


Apex Class:

public with sharing class makeRequired { 

    public String str {Get;set;}
    
    public makeRequired() {
    }    
 
}

Output:

Change the color in apex:panelBar.

Code Format:

<apex:page sidebar="True">
    <apex:panelBar style="background-color:Orange;" headerStyle="background-color:lightgreen;background-image:none;">
        <apex:panelBarItem label="Line 1">
            Line 1
        </apex:panelBarItem>
        <apex:panelBarItem label="Line 2">
            Line 2
        </apex:panelBarItem>
        <apex:panelBarItem label="Line 3">
            Line 3
        </apex:panelBarItem>
    </apex:panelBar>

</apex:page>

Output:



Thursday, 16 August 2018

Change the color in apex:toolBar

Code Format:


<apex:page sidebar="true">
    <apex:form >
        
           <apex:toolbar style="background-color:yellow;background-image:none;">
           <apex:inputText /> <n> </n>
           </apex:toolbar>

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


Output:



Force.com setup in Visualforce page as Side Bar

Code Format:

<apex:page setup="true">

    www.sfdcforyou.com

</apex:page>


Output: