Monday, June 5, 2017

How to Install the Force.com IDE Plug-In in Eclipse.

Install the Force.com IDE Plug-In

Step 1: Launch Eclipse.

Step 2: Select Help → Install New Software.

Step 3:  Click Add button and write in the Add Repository dialog box,
           Name → Force.com IDE
     Locationhttps://developer.salesforce.com/media/force-ide/eclipse45

→ For Spring ’16 (Force.com IDE v36.0) and earlier Force.com IDE versions, use http://media.developerforce.com/force-ide/eclipse42.

→ Click OK.

→ To install an older version of the plug-in (for example, if you don’t have Java 8), deselect Show only the latest versions of available software.

→ Eclipse downloads the list of available plug-ins and displays them in the Available Software dialog.

Step 4:  Select the Force.com IDE plug-in, and then click Next.

Step 5:  In the Install Details dialog, click Next.

Step 6:  In the Review Licenses dialog, accept the terms and click Finish.

→ In step 4, If you choose to install support for Lightning components, Eclipse displays a warning dialog about installing software that contains unsigned content. We are bundling third-party plug-ins to support Lightning components. Salesforce doesn’t own these third-party plug-ins; hence, we don’t sign them. Click OK to proceed.

→ Eclipse downloads and installs the Force.com IDE and the required dependencies. When the installation is complete, you are prompted to restart. Click Yes.

→ When Eclipse restarts, select Window → Open Perspective → Other. Select Force.com and then click OK.

→ You are now ready to develop and customize Force.com applications in Eclipse!



Sunday, June 4, 2017

Apex - Class


Apex - Class

A class is a template or blueprint from which objects are created. An object is an instance of a class. This is standard definition of Class.

→ 3 ways to create apex class in salesforce
  1.   Apex Class
  2.  Apex from Developer Console
  3.  Force.com Eclipse IDE

    From Apex Class:

     Step 1: Click on Setup option. (Top right side on Org)

     Step 2: Search 'Apex Class' in Quick find box and click on Apex Classes link. It will open the Apex Class details page.

      



     Step 3: Click on 'New' button to create new Class.
          



     Step 4: Write code here and then click on save button.
     


From Developer Console:

    Step 1: Go to Name and click on Developer Console.
    Step 2: Click on File menu New and then click on Apex class.

    Step 3: Write Class name and click on OK button.

    Step 4: Write code here.



   From Force.com IDE:
     Step 1: Open Force.com – Eclipse.

    Step 2: Create a New project by clicking on File New Apex Class.

   
    Step 3: Write the Name of Class and click on Finish button.



    Step 4: Once this is done, the new class will be created.

  
    Syntax:
    private | public | global 
    [virtual | abstract | with sharing | without sharing] 
    class ClassName [implements InterfaceNameList] [extends ClassName] 
    { 
      // Classs Body
    }

    Example:

    public class Sampleclass
    {       
         public static Integer a1 = 0; 
         public static Integer getmultiValue()
        {
                 a1 = a1 * 10;
                 return a1;
        }
    }

   


Friday, May 26, 2017

Salesforce Collections.

Salesforce Collections 
(List, Set & Map)

List:
→ List is a collection of elements, Such as primitive data types (String, Integer, Date, etc), user defined objects, sObjects, Apex objects or other collections (can be multidimensional up to 5 levels).
→ List allows duplicate values.
→ List index position starts from zero.

Syntax: List<datatype> listName = new List <datatype>();

List Methods:

1. add()
→ Add value in List.
→ Ex.
     List <string> fruits = new List <string>();
     fruits.add('Apple');
     fruits.add('Orange');
     fruits.add('Banana');
     fruits.add('Grape');

OR

List <string> fruits = new List <string>{'Apple','Orange','Banana','Grape'};

2. get()
→ Retrieve a value from the list using Index.
→ Ex.
     String getfruit = fruits.get(1);
          - We get 'Orange' fruit form list using getfruit variable.

3. set()
→ Replace a value with the value at given Index parameter.
→ Ex.
     fruits.set(3,'Strawberry');  
          - In List value has been changed at the index 3. 'Grape' is replace to 'Strawberry'

4. size()
→ Return the number of elements in the List.
→ Ex.
     fruits.size();
          - Give the size of fruits list is 3.

5. clear()
→ Remove the elements from the list.
→ Ex.
     fruits.clear();          

For more List methods.


Set:
→ Set is a collection of unique, unordered elements.
→ It can contain primitive data types (String, Integer, Date, etc) or sObjects.
→ Set allows unique values.

Syntax: Set<datatype> SetName = new Set <datatype>();

Set Methods:

1. add()
→ Adds an element to the set if it is not already present.

2. contains()
→ Returns true if the set contains the specified element.

3. equals()
→ Compares this set with the specified set and returns true if both sets are equal; otherwise, returns false.

4. size()
→ Returns the number of elements in the set.

5. remove()
→ Removes the specified element from the set if it is present. 

For more Set methods


Map:
→ Map is a collection of key-value pair.
→ Keys can be any primitive data types (String, Integer, Date, etc) while values can include primitives, Apex objects, sObjects and other collections.
→ Map allows duplicate values, but each key must be unique.

Syntax: map<datatype,datatype> MapName = new map <datatype,datatype>();

Map Methods:

1. get(key)
→ Returns the value to which the specified key is mapped, or null if the map contains no value for this key.

2. put(key, value)
→ Associates the specified value with the specified key in the map.

3. remove(key)
→ Removes the mapping for the specified key from the map, if present, and returns the corresponding value.

4. size()
→ Returns the number of key-value pairs in the map.

5. values()
→ Returns a list that contains all the values in the map.

For more Map methods




Saturday, May 20, 2017

Apex - Primitive Data types

Apex - Primitive Data types
    • Integer
    • Decimal
    • Double
    • Long
    • Date
    • Datetime
    • String
    • ID
    • Boolean
       1.      Integer
             → 32-bit number without include decimal point.
             → Ex:
       Integer intNumber = 70;
       system.debug('Value of intNumber variable -> '+ intnumber);
     
     2.      Decimal
           → A number that includes a decimal point.
           → Decimal is an arbitrary precision number.
           → Currency fields are automatically assigned the type Decimal.
        
     3.      Double
           → 64 - bit number that includes a decimal point.
           → Doubles have a minimum value of -263 and a maximum value of 263-1
           → Ex:
        double pi = 3.14159;
        system.debug('Value of pi variable -> '+ pi);

     4.      Long
           → 64 - bit number that does not include a decimal point.
           → Longs have a minimum value of -263 and a maximum value of 263-1.
           → Use this data type when you need a range of values wider than the range provided by Integer.
           → Ex:
        Long ln = 214748985683648L;
        system.debug('Value of long variable -> '+ ln);

      5.      Date
           → A value that indicates a particular day.
           → Date values not contain information about time.
           → Date values must always be created with a system static method.
           → Ex:
        Date dtDate = date.today();
        System.debug('Today Date -> '+dtDate);

     6.      Datetime
           → A value that indicates a particular day and time, such as a timestamp.
           → Datetime values must always be created with a system static method.

     7.      String
           → Set of meaningful characters surrounded by single quotes.
           → It does not have limit on the number of characters they can include.
           → Instead, the heap size limit is used to ensure that your Apex programs don't grow too large.
           → Strings can be manipulated with several standard methods.
           → Ex:

         String specialStr = 'The quick brown fox jumped over the lazy dog.';
         System.debug('Special string -> ' + specialStr);

     8.      ID
           → Any valid 18-character Force.com record identifier.
           → If you set ID to a 15-character value, Apex converts the value to its 18-character representation.
           → Ex:
           ID id='00300000003T2PGAA0';

     9.      Boolean
           → A value that can only be assigned true, false, or null.
           → This type of variables can be used as flag in programming to identify the particular condition set or not set.
           → Ex:
           Boolean youCan = true;