Step by Step Salesforce Tutorial – Creating custom object – 1 of 6

  1. Creating custom object
  2. Creating Fields
  3. Creating Tab and Validation Rule
  4. Creating Email Template
  5. Creating Workflow rule
  6. Creating Trigger and Test cases

Salesforce.com or SFDC is award wining CRM tool and many companies have started using the Salesforce because of flexibility, userfriendly and lots of applications available.

Prerequesties:

To start with this series, you must have below softwares:

  1. Developer Account of Salesforce
  2. Eclipse with Salesforce Plugin
  3. Internet Connection

Developer Account can be created, free of cost from here.

In previous article i have demonstrated that how to install force.com IDE in eclipse.

So, if you have above softwares then we can start with the actual development of application.

here, i hope that you have setup the eclipse with your salesforce account.

Right click on Salesforce project in eclipse and select Object (Custom object).

Below screen will appear.

Create Custom object Eclipse Salesforce
Create Custom object Eclipse Salesforce

For this tutorial, i am creating student object. so in rest of tutorial we will continue with this object.

We can create a custom object through salesforce also instead of eclipse, check below snap:

Create Custom object In Salesforce
Create Custom object In Salesforce

As you can see in above image :

Go to Setup -> App Setup -> Create -> Objects and click on “New Custom object“.

In the next article i will demonstrate, ho to create Fields in Salesforce.

Posted

in

by

Tags:


Related Posts

Comments

10 responses to “Step by Step Salesforce Tutorial – Creating custom object – 1 of 6”

  1. Souvik Bose Avatar
    Souvik Bose

    Getting below mentioned error message.
    Force.com Projects require an Organization with the metadata API enabled.
    API is not enabled for this organization or Partner.

  2. hima Avatar
    hima

    how to check whether API is enable or not?

    1. JitendraZaa Avatar
      JitendraZaa

      At Profile there is check box (Permission) for API.

  3. hollw jamal Avatar
    hollw jamal

    do u have any idea about how can i make an instance of my custom object, to be able to use in Apex Class ?

  4. thulasi ram Avatar
    thulasi ram

    how to write trigger a record with out saving in to the database in salesforce

  5. MyCloud Project Avatar
    MyCloud Project

    Hi , I’ve written a Trigger to assign a task whenever we insert an OpportunityTeamMember to an Opportunity and i also written a Test Case for it but the code coverage is 0%. Can you please check it and tell me where it is going wrong.

    Trigger :

    trigger TaskOnOppTeamMember on OpportunityTeamMember (after insert) {

    list NewTask = new list();

    if(trigger.IsInsert) {

    for(OpportunityTeamMember oppTeam : trigger.new) {

    Task tasksInsert = new Task();

    tasksInsert.WhatId = OppTeam.Opportunityid;

    tasksInsert.OwnerId = oppTeam.Userid;

    tasksInsert.Subject = ‘Great Daddy’;

    tasksInsert.ActivityDate = date.today();

    tasksInsert.Priority = ‘Normal’;

    NewTask.add(tasksInsert);

    }

    }

    Database.insert(NewTask);

    }

    Test Case :

    @isTest

    public class TestCreateTaskTrigger {

    public static testMethod void createTaskTrigger() {

    Opportunity opp = new Opportunity();

    opp.Name = ‘TestOppo’;

    opp.CloseDate = System.Today();

    opp.StageName = ‘Prospecting’;

    insert opp;

    OpportunityTeamMember otMember = new OpportunityTeamMember();

    otMember.OpportunityId = opp.Id;

    otMember.UserId = ‘005900000023dh0’;

    otMember.TeamMemberRole = ‘CFO’;

    insert otMember;

    }

    }

    Thanks,!

    1. JitendraZaa Avatar
      JitendraZaa

      How you are adding this hardcoded line “otMember.UserId = ‘005900000023dh0’;”.

      You need to first insert User and then use ID of inserted user in above line.

      1. MyCloud Project Avatar
        MyCloud Project

        Hi, I am sorry i am brand new to salesforce so please dont think it as silly doubt and help me. I’ve changed it to below code still it is showing 0% code coverage but the Test is Pass.

        @isTest
        public class TestCreateTaskTrigger {
        public static testMethod void createTaskTrigger() {

        User u1 = [SELECT Id, Name FROM User WHERE Alias=’mruiz’];
        System.debug(‘1111111111111’+u1.Name);

        Opportunity opp = new Opportunity();
        opp.Name = ‘TestOppo’;
        opp.CloseDate = System.Today();
        opp.StageName = ‘Prospecting’;
        System.debug(‘11111111111111’+opp);
        insert opp;

        OpportunityTeamMember otMember = new OpportunityTeamMember();
        otMember.OpportunityId = opp.Id;
        otMember.UserId = u1.Id;
        otMember.TeamMemberRole = ‘CFO’ ;
        System.debug(‘222222222222222’+otMember);
        insert otMember;
        }
        }

        Thanks,!

        1. JitendraZaa Avatar
          JitendraZaa

          How you are checking test coverage ? Navigate to Setup | Develope | Apex Test Execution and from this place select your test class and run it. Coverage line will be visible in Development Console.

          1. MyCloud Project Avatar
            MyCloud Project

            Hi, After Running the Test class , I am refreshing the Trigger Detail Page where we can see the code coverage : 0% (0/15).

            Thanks,!

Leave a Reply to himaCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading