• Chaitra Padashetty 23
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello. I need to convert a Lead with LeadConvert and change an opp's Name like this: 'AccountName + DateTime.now'. How can I do that? This doesn't work:

for (Lead lead : Trigger.new) { 
        if (lead.isConverted == false && lead.Status == 'Closed - Converted') {
            lc.setLeadId(lead.Id);   
            lc.setConvertedStatus(convertStatus.MasterLabel);
            lcList.add(lc);
            
            String s = String.valueOf(lc.getAccountId());
         	String b = String.valueOfGmt(Datetime.now());
            lc.setOpportunityName(s + b);
            
            List<Database.LeadConvertResult> lcrList = Database.convertLead(lcList,false);
     }
I become 'null+DateTime.now'. How can I take AccName before Database.convertLead? :(