+ Start a Discussion
unidhaunidha 

How to post code in Discussion Forum?

I remembered last time I can format the code, but I am not able to see any icon to format code either in IE or Chrome.What happen?How to post code here?


trigger Opportunity_Trigger on Opportunity (before insert) { if (Trigger.isBefore) { if(Trigger.isInsert) { OpportunityTriggerHandler.populateDefaultData (Trigger.new); } } }
Best Answer chosen by unidha
Vasani ParthVasani Parth
Hi Unidha - Here is the brief answer to this :

User-added image

Click on the '<>' icon and paste your code there. Thanks

Please mark this as the best answer if this helps

All Answers

JyothsnaJyothsna (Salesforce Developers) 
Hi,

Please click the < > symbol it will open add code sample.For your reference, I am attaching the  screenshot please check it once.


User-added image
Hope this helps you!
Best regards,
Jyothsna
 
 
Vasani ParthVasani Parth
Hi Unidha - Here is the brief answer to this :

User-added image

Click on the '<>' icon and paste your code there. Thanks

Please mark this as the best answer if this helps
This was selected as the best answer
unidhaunidha
Oh , that is so clear =)
nagesh chintala 4nagesh chintala 4
public class Lead_update {
 public Lead l {set;get;}
    public Lead_update(Apexpages.StandardController controller){
        List<string> fields=new List<string>{'name','phone','email','rating'};
          controller.addFields(fields); 
        leads=(List<Lead>)controller.getRecord();
            }
    public PageReference invoke(){
        List<Messaging.SingleEmailMessage> emails=new List<Messaging.SingleEmailMessage>();
        Messaging.SingleEmailMessage msg=new Messaging.SingleEmailMessage();
        for(Lead l:leads){
            string[] toadd=new string[]{l.email};
            String body='Dear '+l.name;
            body=body+'<br/> Update your lead details <br/>';
            body=body+'EMail :'+l.email+'<br/> Phone :'+l.phone+'<br/> Thanks <br/> Sales Team';
            msg.setSubject('Update lead Details');
            msg.setToAddresses(toadd);
            msg.setHtmlBody(body);
            emails.add(msg);
        }
        Messaging.sendEmail(emails);
        PageReference p=  new PageReference('/'+001);
        return p;
      }
  }

 
nagesh chintala 4nagesh chintala 4
Please help for above code i am getting error like Incompatible types since an instance of SObject is never an instance of List<Lead>
nagesh chintala 4nagesh chintala 4
public class Lead_update {
 public Lead l {set;get;}
    public Lead_update(Apexpages.StandardController controller){
        List<string> fields=new List<string>{'name','phone','email','rating'};
          controller.addFields(fields); 
        leads=(List<Lead>)controller.getRecord();
            }
    public PageReference invoke(){
        List<Messaging.SingleEmailMessage> emails=new List<Messaging.SingleEmailMessage>();
        Messaging.SingleEmailMessage msg=new Messaging.SingleEmailMessage();
        for(Lead l:leads){
            string[] toadd=new string[]{l.email};
            String body='Dear '+l.name;
            body=body+'<br/> Update your lead details <br/>';
            body=body+'EMail :'+l.email+'<br/> Phone :'+l.phone+'<br/> Thanks <br/> Sales Team';
            msg.setSubject('Update lead Details');
            msg.setToAddresses(toadd);
            msg.setHtmlBody(body);
            emails.add(msg);
        }
        Messaging.sendEmail(emails);
        PageReference p=  new PageReference('/'+001);
        return p;
      }
  }
please help for above code for incopatble type since instance of sobject is never an instance of list