Step by Step Salesforce Tutorial – Creating Trigger and Test cases – 6 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

This is the last tutorial in series and we will see that how to create a Trigger and Test Cases in salesforce.

A trigger is an Apex script that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.

Triggers are stored as metadata in Salesforce.com. A list of all triggers in your organization is located at SetupDevelopApex Triggers. In addition to this list, triggers are associated and stored with specific objects.

To define a trigger:

  1. For a standard object, click SetupCustomize, click the name of the object, then click Triggers.For a custom object, click SetupCreateObjects and click the name of the object.For campaign members, click SetupCustomizeCampaignsCampaign MemberTriggers.For case comments, click SetupCasesCase CommentsTriggers.

    For email messages, click SetupCasesEmail MessagesTriggers.

  2. In the Triggers related list, click New.
  3. Click Version Settings to specify the version of Apex and the API used with this trigger. If your organization has installed managed packages from the AppExchange, you can also specify which version of each managed package to use with this trigger. Generally, you should use the default values for all versions. This associates the trigger with the most recent version of Apex and the API, as well as each managed package. You can specify an older version of a managed package if you want to access components or functionality that differs from the most recent package version. You can specify an older version of Apex and the API to maintain specific behavior.
  4. Select the Is Active checkbox if the trigger should be compiled and enabled. Leave this checkbox deselected if you only want to store the script in your organization’s metadata. This checkbox is selected by default.
  5. In the Body text box, enter the Apex for the trigger. A single trigger can be up to “1 million” characters in length.

Read this URL for Governor limit reference.

To define a trigger, use the following syntax:

trigger triggerName on ObjectName (trigger_events) {
   code_block
}

where trigger_events can be a comma-separated list of one or more of the following events:

  • before insert
  • before update
  • before delete
  • after insert
  • after update
  • after delete
  • after undelete

So, lets start with creating trigger.

I want that duplicate student should not be created on the basis of Email id. we can achieve this by other way also, like during creation of email field, we can specify it as unique field.

Open eclipse and right click on salesforce project and select Create new Trigger, as shown in below image

Creating Trigger in Salesforce using force.com IDE
Creating Trigger in Salesforce using force.com IDE

As you can see, to create trigger we have to select the Apex version and operations in wizard.

During Trigger creation, keep in mind that it may be required in bulk operations so governor limit may be problem.

So instead of getting query for all triggers individually, I created an array and after that created a set of email entered for all records, and loop through all records invidually and checked for duplicity.
Only one SOQL is fired instead of all triggers individually and thus can work for bulk insert.

For SOQL Best Practice refer :
http://wiki.developerforce.com/index.php/Best_Practice:_Avoid_SOQL_Queries_ Inside_FOR_Loops

trigger DuplicateStudentCheck on Student__c (before insert) {

       //Get all Student__c related to the incoming Student records in a single SOQL query.
       Student__c[] studentsList = Trigger.new;
       Set emailSet = new Set();
       for(Student__c s : studentsList)
       {
       	emailSet.add(s.Email__c);
       }

       //Get list of duplicate Students
       List duplicateStudentList = [Select s.Name, s.Email__c From Student__c s
where s.Email__c IN :emailSet];

       Set duplicateEmailIds = new Set();

       for(Student__c s : duplicateStudentList)
       {
       	duplicateEmailIds.add(s.Email__c);
       }

       for(Student__c s : studentsList)
       {
       	    if(duplicateEmailIds.contains(s.Email__c))
       	    {
       	    	s.Email__c.addError('Record already exist with same email Id');
       	    }
       }
}

Note: You can add, edit, or delete Apex using the Salesforce.com user interface only in a Developer Edition organization, a Salesforce.com Enterprise Edition trial organization, or sandbox organization. In a Salesforce.com production organization, you can only make changes to Apex by using the Metadata API deploy call, the Force.com IDE, or theForce.com Migration Tool. The Force.com IDE and Force.com Migration Tool are free resources provided by salesforce.com to support its users and partners, but are not considered part of our Services for purposes of the salesforce.com Master Subscription Agreement.

Test Cases in Salesforce :


Test case integral part of code developement.

  • You must have at least 75% of your Apex scripts covered by unit tests to deploy your scripts to production environments. In addition, all triggers should have some test coverage.
  • Salesforce.com recommends that you have 100% of your scripts covered by unit tests, where possible.
  • Calls to
    System.debug are not counted as part of Apex code coverage in unit tests.

So, here we are going to create Test Case for trigger which we have written:

@isTest
private class TestTriggers {

    static testMethod void myUnitTest() {
        Student__c s = new Student__c();
        s.Name = 'Om Test';
        s.l_Name__c = 'LastName';

        Course__c c = new Course__c();
        c.Name = 'SFDC';
        c.Fees__c = 2000;
        insert c;

        s.Course__c = c.Id;
        s.Installment_1__c = 2000;
        s.Email__c = 'admin@JitendraZaa.com';
        try
        {
        	insert s;
        }
        catch(System.DMLException e)
        {
        	System.assert(e.getMessage().contains('Record already exist with same email Id'));
        }
    }
}

To run the test case from Eclipse, right click on test class as shown in below image:

Run Test Case using Eclipse in Salesforce
Run Test Case using Eclipse in Salesforce

The output of the test case, Test coverage result:

Test Coverage result Eclipse in Salesforce
Test Coverage result Eclipse in Salesforce

Run test cases from salesforce.com browser:

click SetupDevelopApex Classes, click the name of the class, then click Run Test. If your class calls another class or causes a trigger to execute, those Apex scripts are included in the total amount used for calculating the percentage of code covered.

To run all the unit tests in your organization, click SetupDevelopApex Classes, then click Run All Tests.

Posted

in

by


Related Posts

Comments

97 responses to “Step by Step Salesforce Tutorial – Creating Trigger and Test cases – 6 of 6”

  1. Cloud-Ling Avatar
    Cloud-Ling

    Hi, thanks for your post, it’s really helpful especially with newbies like me. How come my addError method doesn’t come up with it should’ve done?
    here’s the error message every time i try my code

    Apex trigger ErrorDuplicateOutput caused an unexpected exception, contact your administrator: ErrorDuplicateOutput: execution of BeforeInsert caused by: System.FinalException: SObject row does not allow errors: Trigger.ErrorDuplicateOutput: line 11, column 5

    here’s my code where I compiled with no errors,

    trigger ErrorDuplicateOutput on Account (before insert, before update)
    {
    List accList =new List();
    Set b = new Set{‘Express Logistics and Transport’,’Edge Communications’};
    accList = [Select Id, Name FROM Account Where Name in: b];

    for (Account acc : accList)
    {
    if (b.contains(acc.Name))
    {
    acc.Name.addError(”);
    }
    }
    update accList;
    }

    your help will be very much appreciated!
    Cloud-Ling

    1. Rameshreddygunda Avatar
      Rameshreddygunda

      can any one help me in writting a trigger for related list concept….I had Accounts and for it related list i had contacts and if i fill the Accounts and click on save i get the realated list contact and if i enter the same birthday (B.date field)  for two contact records it should throw an error Make sure that you are working on the same Account related list.  

  2. admin Avatar

    Hi Cloud-Ling,
    Please try this:

    trigger ErrorDuplicateOutput on Account (before insert, before update)
    {
    List accList = Trigger.New;

    Set b = new Set{‘Express Logistics and Transport’,’Edge Communications’};

    for (Account acc1 : accList)
    {
    if (b.contains(acc1.Name))
    {
    acc1.Name.addError(‘This is error Message’);
    }
    }
    update accList;
    }

    /*
    * You cannot add error message in existing object, you can add message on object on which operation is performed.
    */

    Thanks,
    Jitendra Zaa

  3. sreekanth Avatar
    sreekanth

    nice info, thanks a lot its very useful..

  4. Narasimha Avatar
    Narasimha

    Ya its good!
    Thanku so much.

    1. Jitendra Zaa Avatar

      Thanks Narasimha.

  5. omni Avatar
    omni

    ohk sir i need to update my object(position) no_of_openings__c which is a picklist whn the status STATUS=recruited of another object (job application)
    no_of_openings__c=Remainings__c-1; how do i proceed im a newbie

  6. Jitendra Zaa Avatar

    Hi Omni,
    If Both object are in relation then u can use “before Trigger” on object (position).

    Thanks,
    Jitendra Zaa

    1. Sangeeta Bhatia Avatar
      Sangeeta Bhatia

      hi all, i am not a coder at all but consider myself trainable 😉 i am looking to update a field in Opportunity object by copying data from a field in the related account object. I have been struggling with it for a while now. Any help will be highly appreciated. Thanks

      1. JitendraZaa Avatar
        JitendraZaa

        You can try to create Formula field. Opportunity can access all fields of its parent Account using formula field.

        1. Sangeeta Bhatia Avatar
          Sangeeta Bhatia

          yes that would have been the solution but unfortunately cant do that because we dont want to lock it down. This opportunity field should take the value from another field on accounts object on insert should still be editable so cant do formula field

          1. JitendraZaa Avatar
            JitendraZaa

            So, you can create Workflow Rule when Opportunity get created. And use field update. WHile updating field get value from Account record.

  7. omni Avatar
    omni

    this is the code

    trigger trg on position__c (after insert,after update)
    {

    position__c ps = [ select Remainings__c,Openings__c from position__c];
    if(trigger.new(0)status__c==’recruited’)
    {
    ps.Remainings__c = ps.Openings__c – 1;
    }
    update ps;

    }

    nd the error i get isError: Compile Error: expecting a right parentheses, found ‘status__c’ at line 5 column 17

    1. Jitendra Zaa Avatar

      Hi try below code :

      trigger trg on position__c (after insert,after update)
      {

      position__c ps = trigger.new[0];
      if(ps.status__c==’recruited’)
      {
      ps.Remainings__c = ps.Openings__c – 1;
      }
      update ps;

      }

  8. omni Avatar
    omni

    now this error

    Error: Compile Error: line 5:17 no viable alternative at character ‘’’ at line 5 column 17

  9. omni Avatar
    omni

    Error: Compile Error: expecting a right parentheses, found ‘status__c’ at line 5 column 17

  10. priya Avatar
    priya

    am getting this error,no viable alternative at character ” when i try fetching records from salesforce.Any help would be greatly appreciated.

    1. Jitendra Zaa Avatar

      Hi Priya,
      Instead of double quotes (“) , use single Quotes (‘)
      OR
      in SOQL query use escape sequence – instead of (‘) use (’)

      Regards,
      Jitendra Zaa

  11. priya Avatar
    priya

    Hi Jitendra,
    i just want to make sure is this the format u’ve suggested while fetching from sfdc?

    CREATEDDATE=’9/5/2011 12:00:00 AM’

    Regards,
    Priya

    1. Jitendra Zaa Avatar

      Yes,
      Example –
      global final String gstrQuery = ‘SELECT ID, StageName, Designated_Contact_Count__C from Opportunity where StageName != ‘Expired”;

      Please reply that it worked or not?
      Regards,
      Jitendra Zaa

  12. priya Avatar
    priya

    Hi Jitendra,

    I was getting the error only when i tried with ‘Date’.So when i try giving like this,

    CREATEDDATE=’9/5/2011 12:00:00 AM’

    i was getting the same error.

  13. HImanshu Avatar
    HImanshu

    I am facing one issue. I want to show trigger error message as html for example. I have following code

    c.addError(‘cannot be rejected through this screen.click < a href="#" rel="nofollow" >here< /a > to Approve/Reject’);

    But it shows as normal text without any hyperlink.

    1. Jitendra Zaa Avatar

      Hi Himanshu,
      It works perfectly. Check below code snap:

      trigger AddLinkInError on Student__c (before insert) {
      Student__c[] studentsList = Trigger.new;
      for(Student__c s : studentsList )
      {
      s.adderror('< a href = ' www.JitendraZaa.com ' > This is Test < / a >. ');
      }
      }

      Regards,
      Jitendra Zaa

    2. Jitendra Zaa Avatar

      Hi Himanshu,
      Any luck on this problem ?

      Regards,
      Jitendra Zaa

  14. Himanshu Avatar
    Himanshu

    It works fine in apex page but on native page it doesn’t come as html

  15. Himanshu Avatar
    Himanshu

    nope

  16. Ashish yadav Avatar
    Ashish yadav

    A single trigger can be up to 32,000 characters in length is wrong its 1 million not 32000 please correct

    1. Jitendra Zaa Avatar

      Thanks Ashish for pointing it out. It was 32,000 at the time when i wrote this article. Now its updated.

      Regards,
      Jitendra Zaa

  17. Michael Gallagher Avatar

    @58580936bae722b65524173157e34bc3:disqus in looking at your code, I’m fairly certain that if I insert two students with the same email address, in the same batch, it will allow them both to be inserted

    1.  Avatar
      Anonymous

      Hey Michael,
      Thanks for reviewing the code.
      I have tested code and its working fine. Any reason or bug you find in above code?

      1. Michael Gallagher Avatar

        Hi Jitendra,
        I’m referring to batch DML, for example something like:insert new Student__c[]{new Student__c(Email__c=’notInDatabase@ notInDatabase.com’), new Student__c(Email__c=’notInDatabase@ notInDatabase.com’)};
        Both student records will be inserted into the database at the same time, as part of the same batch, with duplicate email addresses. See what I mean now?
        Regards,
        Mike

        1.  Avatar
          Anonymous

          Yeah.. You are right. I am comparing with existing records only and skipped the condition to check duplicate email Id within batch.

          Thank you so much for your time.

          Regards,
          Jitendra Zaa

  18. Arun Avatar
    Arun

    07204651195

  19. Lakshmi Sf6 Avatar
    Lakshmi Sf6

    hi 
    i am Lakshmi
    I started learning salesforce
    i completed ECE ,bcz of electronics dept im not able to understand your code
    i am poor in programming,
    i want to learn apex language
    could u pls provide me some material
    in sales force for developer what should i need to learn
    i am unable to understand triggers code
    provide me some simple examples  or material to understand.
    i am afraid of coding and programming, but i wish to learn it and to get ajob in salesforce as a developer,
    my mail id : lakshmi.sf6@gmail.com 
                      luxmi85@gmail:disqus.com

    Thanks & Regards
    lakshmi.

    1. Surendrak188 Avatar
      Surendrak188

       there are many videos uploaded in you tube as a beginner to the sales force you can get some basic  idea later u can go fr documentation hopes it helps u

      Regards,
      Surendra

  20. Lakshmi Sf6 Avatar
    Lakshmi Sf6

    sorry the other one is luxmi085@gmail.com

  21. Amarnagumanni Avatar
    Amarnagumanni

    which language is the relation of salesforce

  22. Ravikumaru007 Avatar
    Ravikumaru007

     how to generate Mr. before all records using apex trigger.

    plz… send me code for my mail     ravikumaru007@gmail.com

  23. Sakshigandhi261 Avatar
    Sakshigandhi261

    hii,
     plzz tel me another way to write error message in triger except this:
    trigger test on Account (before insert) {
    trigger.new[0].name.addError(‘Nice try’);
    }

    1. JitendraZaa Avatar
      JitendraZaa

      Hi,
      Either you can add error message at field level or object level.

      Your code explains the field level, below example is at object level:

      trigger test on Account (before insert) {trigger.new[0].addError(‘Nice try’);} 

      1. Thippirisettyganesh Avatar
        Thippirisettyganesh

        hi jitendra, i posted the question in boards.com please see that one. and give the reply

  24. Amitendra Dixit Avatar
    Amitendra Dixit

    Hi I have installed package RelationShip Group( households) … There is related list on the detailed page of this package object.. The list name is Review Schedule, but this object have no relationship with the object Review_Schedule or the objects that are child of Review Schedule…

    So in the Related List how the record is visible… Please help me …
    tell how its happen… Thanks..

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Amitendra,
      There must be lookup field in Child Object for Parent.
      If its not there then it possible that they are using custom VF page.
      But i am sure that there is lookup field in child object. You can send me the screen shot, then i can answer in better way.

      1. Amitendra Dixit Avatar
        Amitendra Dixit

         Thanks Jitendra for your information.

        I have solved this problem. Actually there was a object which had lookup with RelationShip Group object and master Details with other object. Therefore it is happen, without direct relationship. Relations between object like this image.

  25. Amitendra Dixit Avatar
    Amitendra Dixit

     Hi Jitendra,

    I am to use a tool “DBAmp” in my application. This is a paid tool. It can intigrate with Sql Server 2005 version or later. We can get backup of salesforce app data in sql using this tool.

    I have problem in configuration and login by this tool. will you help me about this..?, Please..

  26. Amitendra Dixit Avatar
    Amitendra Dixit

    Hi
    I am to move the data of a encrypted field from on object to other object. But encrypted field has many restriction like, we can not use it in farmula field. So please tell me what is the option for this.
    please let me no if any option for this.

    Thanks,

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Amitendra,
      You can use Trigger for New records. And if you want to create Objects from existing then you can use Developer console to run Anonymous APEX code

      1. Amitendra Dixit Avatar
        Amitendra Dixit

         Hi Jitendra,

        Thanks for your suggetion. This possible by trigger. But there is no way exxcepting
        trigger. Like, can we do it by using VF page or anyother method?
        If any option please tell me …

        Thanks,

        1. JitendraZaa Avatar
          JitendraZaa

          Then you can use Schedular Class.

  27. Amitendra Dixit Avatar
    Amitendra Dixit

    Hi

    I am to create a report that I have attached in the image ..
    please help me, It is cutom type report. 

    Thanks,

    1. JitendraZaa Avatar
      JitendraZaa

      Hi dont think that it is possible using Report builder. Either your schema should support this or You need to write custom VF Page.

  28. smita Avatar
    smita

    Hi Jeetendra,
    This is smita .New to salesforce software in my org.
    Wanted to check 2 things ,looking for some help on this regards:
    I have created around 70 leads with the for our company’s client.
    Now if i want can i set-up a remainder or alert wherein i get a alert or remainder popup to update the status with the latest status,or for that matter even if i have to follow-up remainder or alert mechanism.

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Smita,
      There are lots of ways but i am explaining the easiest way in which no Apex involved.
      Steps:
      1: Create temp field of checkbox type. Dont add this field on any page layout, it should be hidden.
      2.Create workflow rule to update (toggle) that field.
      3.Create other time dependent workflow rule which will check last modify date with current date. if record not modified in last 10 days then send email.

      Note : For existing leads, you will need to update ll the leads using apex.

  29. Amitendra Dixit5 Avatar
    Amitendra Dixit5

    Hi
    I have declear a list as below , but getting error when I am using it
    public List serviceObjects = new List(); 
    Error: Compile Error: Variable does not exist: serviceObject at line 22 column 25

    please let me know why its happen

  30. Amitendra Dixit Avatar
    Amitendra Dixit

    HI
    I have found error when I am parsing a wsdl into salesforce, the error is
    Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}boolean

    Please solve it out why this is happening.

    thanks
    Amitendra

  31. Aruna Vemula Avatar

    Can I write this test class in Salesforce.com….If yes where can I write ode for a particular apex class or a trigger

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Aruna,
      You can write test class in Developer, Enterprise and Unlimited Edition.

      Go to SetuP | Develope | Apex class

  32. ramesh Avatar
    ramesh

    what is difference b/w sales cloud and service cloud.

    what type of cloud salesforce.com?

    1. Anusha Avatar
      Anusha

      Mainly Salescloud:-
      campaign,Account,Contact,Leads,Oppertunities,Chatter,Mobiles,Workflows,Approvals,Appexchange,marketing,quotes e.t.c

      ServiceCloud:-
      Here Only Cases and solutions,contactphone,phone,analyting,workflows,approvals,chatteraccounts,knowledge,customerportal,Appexchange,marketing,mobiles,communication e.t.c

      Salesfore:-
      It is Cloud Paltform More Multitenants are useing the same Service.

  33. Shashy kala Avatar
    Shashy kala

    Hi please someone help me .

    How to write Test Class for this Trigger

    trigger BillingAddPopulateOnCustomAddress on Account (before insert, before update) {

    for(Account acct : Trigger.new){

    if((acct.cust_Address_1__c==null && acct.cust_City__c==null &&
    acct.cust_State__c==null && acct.cust_Country__c==null &&
    acct.cust_Postal_Code__c==null) &&

    ( acct.BillingStreet !=null || acct.BillingCity !=null ||
    acct.BillingCountry !=null || acct.BillingPostalCode !=null ||
    acct.BillingCountry !=null )) {

    //Moving Billing Address to CustomAddress
    acct.cust_Address_1__c = acct.BillingStreet;
    acct.cust_City__c = acct.BillingCity;
    acct.cust_State__c = acct.BillingState;
    acct.cust_Country__c = acct.BillingCountry;
    acct.cust_Postal_Code__c = acct.BillingPostalCode;

    }
    }
    }

  34. kiran Avatar
    kiran

    what is the main difference between before trigger and after trigger

  35. sa Avatar
    sa

    Can u Explain test method and annotations in Apex in salesforce

  36. sriram Avatar
    sriram

    hi the above example shows some when defining set collection ‘

  37. Tom Briggs Avatar
    Tom Briggs

    Hi,
    I wonder if this is the place to ask…
    I’m in need of some help regarding the writing of test script that covers enough of the below trigger that I have managed to get working on my Sandbox account.
    The trigger is to create extra assets when certain types of Opportunities are closed. The Trigger seems to run fine but I really have no idea how to start writing test cases… In order for these Opportunities to close, the Account needs to have the following completed (I’ve included some example data – They are picklists so need to be specif amounts):
    a.TurnoverBand__c = ‘<£10 million';
    a.Joining_Fee__c = '£1,920';
    a.Annual_Subscription__c = '£1,320';

    Trigger as follows:

    trigger CreateInclusiveAssetonMembershipWon on Opportunity (after insert, after update)
    {
    for(Opportunity o: trigger.new)
    {
    if(o.isWon == true && o.HasOpportunityLineItem == true && ( o.Type == 'A Membership' || o.Type == 'AB Membership' || o.Type == 'A Membership Upgrade' || o.Type == 'AB Membership Upgrade' ) )
    {
    String opptyId = o.Id;
    Asset[] ast = new Asset[]{};
    Asset a = new Asset();
    {
    a = new Asset();
    a.AccountId = o.AccountId;
    a.Product2Id = '01tA0000003N1pW';
    a.Quantity = o.Inclusive_Training_Spaces_Allocated__c;
    a.Price = 300;
    a.PurchaseDate = o.CloseDate;
    a.Status = 'Purchased';
    a.Description = 'Allocated Spaces';
    a.Name = 'Membership Inclusive Training';
    ast.add(a);
    }
    insert ast;
    }
    }
    }

    If anyone could help me out on this I would be grateful!

    Thanks

  38. Kriyanshi Avatar
    Kriyanshi

    I m kriyanshi nd passed my btech in ECE trade in 2013 I have little bit knowledge about programming but i want to make my future in salesforce thn how i start to learn the apex language nd all tht pls help me how i increase my programming skills i m not able to understand triggers all that pls help me as soon give me some material to increase my skills

    1. JitendraZaa Avatar
      JitendraZaa

      Hi kriyanshi,

      you need to go step by step. I will suggest you to go through Apex Workbook and try all hands on.

  39. Anusha Avatar
    Anusha

    Hi Sir,
    I am the Salesforce learner at present i am learning trigger concept. I can’t able to understand about trigger.So, Could u Plz Send me any weblink or what ever .becoz i am the fresher so plz help me.

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Anusha, You can have a look on this documentation.

      http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_trigger.htm

  40. Khushbu Shah Avatar
    Khushbu Shah

    Hello jitendrazaa ,

    I don’t know whether i should put my query over here or not. But i believe that you will help me.

    I am having one grid.
    I am having one page in force.com
    I want to refresh my grid when any DML operation don on data.
    I am changing my field records manually..It should refresh my grid view also.

    I don’t know whether I should use trigger for that or not.

    I have used also..

    Please guide me….
    Its in urgent bases..Please help me out..
    Thanks in advance…

  41. Khushbu Shah Avatar
    Khushbu Shah

    hi all

  42. JitendraZaa Avatar
    JitendraZaa

    Hi , You can use Streaming API to detect changes in data in realtime for grid.

    1. Khushbu Shah Avatar
      Khushbu Shah

      Can u please give me some examples of streaming API? As I am a fresher I don’t know much about this all..Please guide me as soon as possible

      1. JitendraZaa Avatar
  43. Dinesh Singla Avatar
    Dinesh Singla

    hi jitendra in salesforce how we can track vehicle current position and based on that we can implement geo fencing can you please suggest me something

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Dinesh,
      There is no Out of box functionality available. You need to write Client program may be in Java or .Net , which track vehicle position using GPS kit and using Web service update record inside salesforce.

      1. Dinesh Singla Avatar
        Dinesh Singla

        i want to write code in salesforce trigger.i am able to track vehicle current position in salesforce using google maps but i am not able to implement geo fencing issue.can you plz suggest me any thing

        1. JitendraZaa Avatar
          JitendraZaa

          Hi Dinesh,
          Can you please explain what exactly u mean by Geo Fencing ? U want to receive SMS or something when vehicle is outside boundry ?

          1. Dinesh Singla Avatar
            Dinesh Singla

            when vehicle go out side 5 km boundary of a predefined route.then i just have to set a variable true

          2. JitendraZaa Avatar
            JitendraZaa

            And how you are tracking vehicle location in google maps ? How you are getting co-ordinates ? There must be some GPS enabled API you are using

          3. Dinesh Singla Avatar
            Dinesh Singla

            we are using gprs device and VB.net code.and getting the location on sales force(using WSDL CLASS).then we are using google v3 maps to track its current position

          4. JitendraZaa Avatar
            JitendraZaa

            In that case, your VB.Net should check if Vehicle is going outside and if it is case then it should call Salesforce Web service. Salesforce Webservcie just have to update variable. MOst of work should be done by VB.Net code only.

  44. Dinesh Singla Avatar
    Dinesh Singla

    hi jitendra.
    i want to know about vehicle tracking system. i am able to track vehicle current position but not able to do geo fencing based on a particular root.can u plz suggest me something

  45. Madhuri Yarlagadda Avatar
    Madhuri Yarlagadda

    i’m finding the error when i;m compiling the above trigger program to prevent duplicates..plz help me why i’m getting the error..

    Error: Compile Error: expecting a semi-colon, found ’emailSet’

    1. JitendraZaa Avatar
      JitendraZaa

      plz post ur code.

  46. Dinesh Singla Avatar
    Dinesh Singla

    hi
    I have build a Ftp server using filezilla server .locally I am able to connect with it.

    but when I try to connect it with https://dataloader.io (after login ->new task->import->after choosing object ->FTP->new connection).

    When I give those credential it showing connection refused.

    In that login what host url we have to use so that we can connect to It.

    I am also using http://ftptest.net/#result to see my ftp connection

    how i make my ip address global so that i can connect plz reply

    1. JitendraZaa Avatar
      JitendraZaa

      Where is your FTP Server ?
      On Local host or somewhere else ?
      If you are trying to connect FTP server present on your local system from DataLoader.io, thrn it is not possible. Your FTP server must be on some public accessible address.

      1. Dinesh Singla Avatar
        Dinesh Singla

        its on local server.
        how to make public accessible server can u plz give me some link or any document so that i will able to connect it to DataLoader.io thanks in advance.

        1. JitendraZaa Avatar
          JitendraZaa

          public means, Computer is on internet. Best way to do is Buy Web Hosting. They provides free FTP Server. You connect dataloader.io with those web servers.
          Making your computer to public is whole lot different path to networking.

  47. Dinesh Singla Avatar
    Dinesh Singla

    hi jitendra
    can we schedule a batch file from salesforce?

    1. JitendraZaa Avatar
      JitendraZaa

      Hi Dinesh, WHat exactly you mean by Schedule batch file ? We can schedule a class. What is your requirement ?

      1. Dinesh Singla Avatar
        Dinesh Singla

        i have to upload a file from a ftp server to salesforce. everyday on 12 pm a scheduler in salesforce execute and its upload a csv file from ftp server to salesforce and vice versa .

        1. JitendraZaa Avatar
          JitendraZaa

          It is possible but only by API. You may need to create Java or .Net middle layer which will connect to Salesforce as well as FTP Server.

  48. Dinesh Singla Avatar
    Dinesh Singla

    i have two object OPP and rate with one common filed data type currency. i am using one vf page and based on the value opp in field i am fetching the data from rate object. in rate object it is stored with comma separated like 34,444.50.

    but when i entring the same value in vf it not showing proper results. while after removing comma it’s showing me proper value

  49. Kapil Tilwani Avatar
    Kapil Tilwani

    Hello Everyone .. I have to do a task where there are two objects say objA and objB(objB is clone of objA) . What i need to do is write a trigger on objA that should all the events(update/insert/delete/undelete) that happens on objA to objB(Reflect all the changes that happens in objA into objB). Let say if insert a record in objA that same record should also b inserted in objB, if i update a record on objA the same record should get updated on objB . (objA and objB contains all kind of fields)

    Much needed help .. and its urget

    Thanks in advance

  50. pretham Avatar
    pretham

    hi
    i am newly for salesforce
    can anyone suggest me sfdc tutorials or refer any sites

  51. Pihu Avatar
    Pihu

    Nice article

  52. Jagan G Avatar
    Jagan G

    Creating custom object
    Creating Fields
    Creating Tab and Validation Rule
    Creating Email Template
    Creating Workflow rule
    Creating Trigger and Test cases

    Those Links are not working properly. Check it out.

    Thanks
    Jagan G

Leave a Reply to Amitendra DixitCancel 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