• Anshul Bagdiya
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            Leadconvert.setLeadId(LeadIds[0]);
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Leadconvert.setConvertedStatus(Leads.MasterLabel);
            Leadconvert.setDoNotCreateOpportunity(TRUE);
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}
Is it enough to prepare for the admin & developer certifcation exam through trailhed ???
Is it enough to prepare for the admin & developer certifcation exam through trailhed ???
Hi.. I am planning to take 201 admin and platform developer 1 or dev 401 within a month or 2. Can you please suggest me some nice free resources on both of these certifications?  Also to be a good salesforce developer, which one is more important ceritfication to take from job point of view as a devloper?
I created the following Apex Class and Apex Trigger. However the code coverage for the Apex Class is only 63% and the Aoex Trigger is 0%.

How do I increase the code coverage for the Apex Class and Apex Trigger?

Apex Class: ApprovedSFDCRequestPDF
Code Coverage: 63% (13/19)
public class ApprovedSFDCRequestPDF
{
    public SFDC__c SFDCReq;
    //public DateTime craDateTime = DateTime.now();
    private ApexPages.StandardController stdController;
    
    public ApprovedSFDCRequestPDF(ApexPages.StandardController stdController)
    {
        this.stdController = stdController;
        SFDCReq = (SFDC__c)stdController.getRecord();
    } 
    // Attach Approved SFDC Request to current SFDC__c 
    
    public PageReference attach()
    {
        DateTime craDateTime = DateTime.now();
        SFDC__c  f=[select id,name,Submitted_for_Approval__c,SFDC_Request_Status__c from SFDC__c where id=:SFDCReq.id];
        if(f.Submitted_for_Approval__c==True&&f.SFDC_Request_Status__c=='Approved')
        {
            // Get the page definition 
            //PageReference pdfPage = Page.ApprovedSFDCRequestPDF;   
            
            PageReference pdfPage = new PageReference('/apex/ApprovedSFDCRequestPDF?id=' + SFDCReq.id);
           
            
            //pdfPage.getParameters().put('id',SFDCReq.id);
             Blob pdfBlob = null;
            // Generate the pdf blob
            if(!Test.isRunningTest())//added by Najma for #00055992
             pdfBlob = pdfPage.getContent();
            else
            pdfBlob = Blob.valueOf('Test');
            //SFDC__c f=[select id,name from SFDC__c where id=:SFDCReq.id];
            // Create the attachment against the Approved SFDC Request page 
            Attachment a = new Attachment(parentId = f.id, name=f.name + ' - SFDC ' + craDateTime.formatlong() + '.pdf', body = pdfBlob);
            // Insert the attachment into the SFDC Request
            
            insert a;
        }
        PageReference p=new PageReference('/'+f.id);
        p.setredirect(true);
        return p;  
    }
}

Apex Trigger:  CreateSFDCRequestTrigger
Code Coverage: 0% (0/3)
trigger CreateSFDCRequestTrigger on SFDC__c (before update) {
     for(SFDC__c  sfdc : trigger.new){
        if(sfdc.FromApprovalProcess__c == true ){
             GenerateCDRPDF.generateCDRPDFAttachment(sfdc.id, 'sfdc', UserInfo.getSessionId());
        }
    }
}

Thanks!

Beth