• Ali White
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
I have managed to create a trigger to help auto convert leads based on certain criteria (code below) but really don't know where to start with writing the test?

__________

rigger AutoConverter on Lead (after insert) {
    //get all the records with Web Form = Free Trial
        for (Lead lead : Trigger.new) {
            if (lead.isConverted == false) {
                if(lead.webform__c=='Free Trial'){
                    //call the single click lead convert method to convert the lead
                       
                    Database.LeadConvert lc = new Database.LeadConvert();
                    lc.setLeadId(lead.Id);

                    String oppName =  lead.Name;
                        lc.setOpportunityName(oppName);

                    LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
                        lc.setConvertedStatus(convertStatus.MasterLabel);
     
                    Database.LeadConvertResult lcr = Database.convertLead(lc);
                        System.assert(lcr.isSuccess());
                }
           }
       }

____________

As I said I have no idea how to create a test for this (I have given the start a go but just get error after error and would embarased to paste what I have created)?

I basically copied the code (with a few amends) from this discussion https://developer.salesforce.com/forums?id=906F00000008xO5IAI 

(copied from penultimate point)

If someone could please help me out that would be greatly appreciated?
I have managed to create a trigger to help auto convert leads based on certain criteria (code below) but really don't know where to start with writing the test?

__________

rigger AutoConverter on Lead (after insert) {
    //get all the records with Web Form = Free Trial
        for (Lead lead : Trigger.new) {
            if (lead.isConverted == false) {
                if(lead.webform__c=='Free Trial'){
                    //call the single click lead convert method to convert the lead
                       
                    Database.LeadConvert lc = new Database.LeadConvert();
                    lc.setLeadId(lead.Id);

                    String oppName =  lead.Name;
                        lc.setOpportunityName(oppName);

                    LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
                        lc.setConvertedStatus(convertStatus.MasterLabel);
     
                    Database.LeadConvertResult lcr = Database.convertLead(lc);
                        System.assert(lcr.isSuccess());
                }
           }
       }

____________

As I said I have no idea how to create a test for this (I have given the start a go but just get error after error and would embarased to paste what I have created)?

I basically copied the code (with a few amends) from this discussion https://developer.salesforce.com/forums?id=906F00000008xO5IAI 

(copied from penultimate point)

If someone could please help me out that would be greatly appreciated?
I recently installed EchoSign for Salesforce and finally have things up and running with my users being able to send documents with a single click. Now, I need to take it one step further and figure out a way to send a contract without user interaction, at the time a record (Lead) is created. 

Adobe talks about workflows in thier marketing but offers no obvious direction as to how to go about setting them up. As far as I can tell, this is not something which is a part of standard workflows so it sounds like I'm going to have to write another trigger??

Well, I've written a few triggers in the past but I am far from an expert. I can do it, I just need something to show me the way... I would appreciate any links or code snippets that anyone could offer. I'm sort of lost at this point and Adobe help & support is basically non-existent.

Thank you!

PS: I know how to find the basic Salesforce help guides on Apex Triggers - I need something specific to EchoSign. Thanks!