• akhil V
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 16
    Replies
Hi ,
Is it possibe to insert multiple pdf's into object after inserting a reocrd?help will be more appreciable
Note:without using webservives

Thanks,
Akhil
HI ,

Please say in short with usage and without usage of seealldata=true with a good example.Please dont keep any links 

Thanks,
akhil
Hi,
Here is the problem i have written a trigger that inserts a record along with that vf created pdf.when i execute from console the reocrd and pdf is inserting when i click on pdf content is exact but when i insert a record manually,pdf is also created but when i download the pdf file it is getting null pdf?please Help out.
 if(!Test.isRunningTest()) 
                    {
                        b = pdf.getContent();
                        
                        System.debug('blobcontent+++++++++++'+b );
                    }
                    else
                    {
                        b = Blob.valueof('Some random String');
                    }
                    
                    n = new Attachment();
                    n.ParentId = id;
                    n.Name = 'Carrier_Confirmation.pdf';
                    
                    n.Body = pdf.getContentAsPDF();
                  
                        //n.Body = Blob.valueof('Some random String');
                 
                    n.IsPrivate = false;
                    n.contentType = 'image/pdf';
                    
                    insert n;
hi,
How to over come 101 soql in test class?
Hi,
Got an Mixed Dml Exception in test class how to over come that ? any help ?
Hi ,
Here i have a requirement please help me the scenario :i have 3 vf pdf documents ,when i insert a record as well i have to insert this 3 pdf's into the object?i want it through trigger any help is appreciable
Hi please send some tirgger code examples to this post it will be more helpfull other than google.It will be more useful and aprreciable
Thank,
Akhil 
Hi ,
Their is a test class that calls another tirgger which is in manged object here i inserted values into managed object still i cant find what sort of validation it is not allowing to save values,any help will be aprreciable.
Thanks,
Akhil
Hi i have a class and need a code coverage for that i wrote a test class bt it is not passing the private method in test class,so i kept @testvisible annotation to private method then it was passed,when i have done the deployment i got a error about @testvisible annoation ?can any one say how to rectify and deploy my code to production.?
Thanks in Advance,
Akhil
please help out to coverage of trigger
List<Contract_Product__c> contractProducts = new List<Contract_Product__c>();
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    opportunityIds.add(oli.OpportunityId);
                    productIds.add(oli.Product2Id);
                }
                
                List<Product2> products = [select id,
                                                ProductCode from Product2 where id in: productIds];
            
                for(Product2 p : products)
                {
                    productMap.put(p.id, p.ProductCode);
                    
                }
            
                List<Contract> contractList = [select id,
                                                      Opportunity_Name__c 
                                                      from Contract 
                                                      where Opportunity_Name__c in: opportunityIds];
                for(String s : opportunityIds)
                {
                    List<String> cList = new List<String>();
                    for(Contract c : contractList)
                    {
                        if(c.Opportunity_Name__c == s)
                        {
                            //contractMap.put(c.Opportunity_Name__c, c.id);
                            cList.add(c.id);
                        }
                    }
                    contractListMap.put(s, cList);
                }
                
                
                System.debug('************ '+contractListMap);
            // Block for Insert Opp Line Items
            
            if(Trigger.isInsert)
            {
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    
                    if(contractListMap.get(oli.OpportunityId) != null)
                    {
                        System.debug('% '+contractListMap.get(oli.OpportunityId));
                        for(String s : contractListMap.get(oli.OpportunityId))
                        {
                            Contract_Product__c c = new Contract_Product__c();
                            System.debug('333333333333'+s);
                            c.Contract__c = s;
                            c.ServiceDate__c = oli.ServiceDate;
                            c.Discount__c = oli.Discount;
                            c.Description__c = oli.Description;
                            c.ListPrice__c = oli.ListPrice;
                            c.Opp_Line_Item_Id__c = oli.id;
                            c.Product__c = oli.Product2Id;
                            c.ProductCode__c = productMap.get(oli.Product2Id);
                            c.Quantity__c = oli.Quantity;
                            c.UnitPrice__c = oli.UnitPrice;
                            
                            contractProducts.add(c);
                        }
                    }
                }
                System.debug('++++++++++++'+contractProducts);
                if(contractProducts.size()>0)
                {
                    insert contractProducts;
                }
                System.debug('-------------- '+contractProducts);
            }
            
            // Block for update line items
            
            if(Trigger.isUpdate)
            {
                List<String> oppLineItemIds = new List<String>();
                List<String> unmatchedOppLineItemIds = new List<String>();
                for(OpportunityLineItem oli : Trigger.new)
                {
                    oppLineItemIds.add(oli.id);
                }
                
                List<Contract_Product__c> contractProdList = [select id, 
                                                                        Contract__c,
                                                                        ServiceDate__c,
                                                                        Discount__c,
                                                                        Description__c,
                                                                        ListPrice__c,
                                                                        Opp_Line_Item_Id__c,
                                                                        Product__c,
                                                                        ProductCode__c,
                                                                        Quantity__c,
                                                                        UnitPrice__c from Contract_Product__c 
                                                                        where Opp_Line_Item_Id__c in : oppLineItemIds ];
                
                
                delete contractProdList;
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    
                    if(contractListMap.get(oli.OpportunityId) != null)
                    {
                        System.debug('% '+contractListMap.get(oli.OpportunityId));
                        for(String s : contractListMap.get(oli.OpportunityId))
                        {
                            Contract_Product__c c = new Contract_Product__c();
                            System.debug('333333333333 update'+s);
                            c.Contract__c = s;
                            c.ServiceDate__c = oli.ServiceDate;
                            c.Discount__c = oli.Discount;
                            c.Description__c = oli.Description;
                            c.ListPrice__c = oli.ListPrice;
                            c.Opp_Line_Item_Id__c = oli.id;
                            c.Product__c = oli.Product2Id;
                            c.ProductCode__c = productMap.get(oli.Product2Id);
                            c.Quantity__c = oli.Quantity;
                            c.UnitPrice__c = oli.UnitPrice;
                            
                            contractProducts.add(c);
                        }
                    } 
public class ctrlJQDatePicker {
  public String dateDefaultValue { get;set; }
}
can any one write a test class for this?
thanks in advance
Hi,
Am getting this Error in a Test  Class .its about 100 lines of code as part of that am not pasting the code,can any one say why this error comes?
Thanks in Advance,
Akhil
if(lo.lat__c == null || lo.long__c == null || (lo.Zip_Code__c != null && Trigger.oldMap.get(lo.id).Zip_Code__c != lo.Zip_Code__c)) getting this error in this statement can one help out urgent
HI,I Need a trigger which calls a class with google Apis based on Zipcode.When I enter Zipcode automaticaly longitude and latitude should be updated?Please Help Me out with code
I have the following trigger.
trigger limitrecordtypes on Evaluation_by_metric__c (before insert,before update) {


if(trigger.isinsert){


list<Evaluation_by_metric__c> recordset=new list<Evaluation_by_metric__c>([select id,recordtypeid,Quarter__c,Metric__c,Month__c from Evaluation_by_metric__c]);


 for(Evaluation_by_metric__c c: trigger.new)
 {
   //mapping close period record with evaluation record before insert
   c.Close_Period__c = [select id from Close_Period__c limit 1].id;
   system.debug('look '+c.Close_Period__c);
   
   if(c.Quarter__c != null)
   {
    for(Evaluation_by_metric__c cv: recordset)
       {
        if(cv.Quarter__c == c.Quarter__c && cv.recordtypeid == c.recordtypeid && cv.Metric__c==c.Metric__c)
         {
          c.Quarter__c.adderror('This Recordtype has been created for this Quarter');
         }
   }
 }
  if(c.Month__c != null)
      {
        for(Evaluation_by_metric__c ebm : recordset)
         {
            if(ebm.Month__c == c.Month__c && ebm.recordtypeid == c.recordtypeid && ebm.Metric__c==c.Metric__c)
              {
            c.Month__c.adderror('This Recordtype has been created for this Month');
              }
         }
      }
  }
 
 }
 
 
if(trigger.isupdate)
{
  list<Evaluation_by_metric__c> recordset1=new list<Evaluation_by_metric__c>([select id,recordtypeid,Quarter__c,Metric__c,Month__c from Evaluation_by_metric__c]);


 for(Evaluation_by_metric__c c: trigger.new){
 
    //mapping close period record with evaluation record before insert
   c.Close_Period__c = [select id from Close_Period__c limit 1].id;
   
 Evaluation_by_metric__c oldAsset=trigger.oldMap.get(c.id);
 system.debug('@@@@@@'+oldAsset);
 
     if(oldAsset.Quarter__c !=null){
 
         for(Evaluation_by_metric__c cv: recordset1){
 
             if(cv.Quarter__c == oldAsset.Quarter__c && cv.recordtypeid == oldAsset.recordtypeid && cv.Metric__c==oldAsset.Metric__c){
             
               cv.quarter__c=oldAsset.Quarter__c;
               cv.recordtypeid = oldAsset.recordtypeid;
               cv.Metric__c=oldAsset.Metric__c;
              
               
                 
 }
 else if(cv.Quarter__c == c.Quarter__c && cv.recordtypeid == c.recordtypeid && cv.Metric__c==c.Metric__c){
 
                 c.Quarter__c.adderror('This Recordtype has been created for this Quarter');
 
 }
 }
 
 
 }
 
 
 
 if(oldAsset.Month__c != null){
 for(Evaluation_by_metric__c ebm: recordset1){
 if(ebm.Month__c == oldAsset.Month__c && ebm.recordtypeid == oldAsset.recordtypeid && ebm.Metric__c==oldAsset.Metric__c){
               ebm.Month__c =oldAsset.Month__c;
               ebm.recordtypeid = oldAsset.recordtypeid;
               ebm.Metric__c=oldAsset.Metric__c;
}
 else if(ebm.Month__c == c.Month__c && ebm.recordtypeid == c.recordtypeid && ebm.Metric__c==c.Metric__c){
 
                 c.Month__c.adderror('This Recordtype has been created for this Quarter');
 
 }
}
}
}










}
}
Can you plzz write the test class code for this trigger?
Thanks in advance.
HI ,

Please say in short with usage and without usage of seealldata=true with a good example.Please dont keep any links 

Thanks,
akhil
Hi,
Here is the problem i have written a trigger that inserts a record along with that vf created pdf.when i execute from console the reocrd and pdf is inserting when i click on pdf content is exact but when i insert a record manually,pdf is also created but when i download the pdf file it is getting null pdf?please Help out.
 if(!Test.isRunningTest()) 
                    {
                        b = pdf.getContent();
                        
                        System.debug('blobcontent+++++++++++'+b );
                    }
                    else
                    {
                        b = Blob.valueof('Some random String');
                    }
                    
                    n = new Attachment();
                    n.ParentId = id;
                    n.Name = 'Carrier_Confirmation.pdf';
                    
                    n.Body = pdf.getContentAsPDF();
                  
                        //n.Body = Blob.valueof('Some random String');
                 
                    n.IsPrivate = false;
                    n.contentType = 'image/pdf';
                    
                    insert n;
hi,
How to over come 101 soql in test class?
Hi,

I have a apex class for which i have test class for it , but its not covering any %, kindly help me on this regard

MY APEX CLASS :


public class IAR_TT_Excel_Export_Controller2 extends IarBaseController{ public string IARId {get;set;} public string GRIDId {get;set;} public IAR_Main__c objIARMain {get;set;} public string IARName {get;set;} public Decimal IARVersion {get;set;} public IAR_TT_Excel_Export_Controller2(){         IARId = ApexPages.currentPage().getParameters().get('IarMain');         GRIDId= ApexPages.currentPage().getParameters().get('id');         //EquipmentType = ApexPages.currentPage().getParameters().get('Type');           if(IARId!=null)             {                 objIARMain = [select Id, Customer_Name__c,IAR_Name__c,Version__c from IAR_Main__c where Id=:IARId LIMIT 1];                            }             IARName=objIARMain.IAR_Name__c;             system.debug('Before==>'+IARName);             IARName=IARName.replace(' ','_');             system.debug('After==>'+IARName);             IARVersion=objIARMain.Version__c;    }    }


MY TEST CLASS:

static testMethod void IAR_TT_Ramp_Controller_Test3() {
 
 //IAR_TT_Excel_Export_Controller2 iarexport  = new IAR_TT_Excel_Export_Controller2();
 
         // Add parameters to page URL
       // ApexPages.currentPage().getParameters().put('IarMain');
       
       
       IAR_Main__c iars1 = new IAR_Main__c();
       iars1.Customer_Requirements_Comments__c='check';
       iars1.Version__c=2;
       insert iars1;
      

 
 
 }

Kindly let me know what  am doing wrong here
thanks in advance
Hi please send some tirgger code examples to this post it will be more helpfull other than google.It will be more useful and aprreciable
Thank,
Akhil 
Hi ,
Their is a test class that calls another tirgger which is in manged object here i inserted values into managed object still i cant find what sort of validation it is not allowing to save values,any help will be aprreciable.
Thanks,
Akhil
Hi i have a class and need a code coverage for that i wrote a test class bt it is not passing the private method in test class,so i kept @testvisible annotation to private method then it was passed,when i have done the deployment i got a error about @testvisible annoation ?can any one say how to rectify and deploy my code to production.?
Thanks in Advance,
Akhil
please help out to coverage of trigger
List<Contract_Product__c> contractProducts = new List<Contract_Product__c>();
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    opportunityIds.add(oli.OpportunityId);
                    productIds.add(oli.Product2Id);
                }
                
                List<Product2> products = [select id,
                                                ProductCode from Product2 where id in: productIds];
            
                for(Product2 p : products)
                {
                    productMap.put(p.id, p.ProductCode);
                    
                }
            
                List<Contract> contractList = [select id,
                                                      Opportunity_Name__c 
                                                      from Contract 
                                                      where Opportunity_Name__c in: opportunityIds];
                for(String s : opportunityIds)
                {
                    List<String> cList = new List<String>();
                    for(Contract c : contractList)
                    {
                        if(c.Opportunity_Name__c == s)
                        {
                            //contractMap.put(c.Opportunity_Name__c, c.id);
                            cList.add(c.id);
                        }
                    }
                    contractListMap.put(s, cList);
                }
                
                
                System.debug('************ '+contractListMap);
            // Block for Insert Opp Line Items
            
            if(Trigger.isInsert)
            {
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    
                    if(contractListMap.get(oli.OpportunityId) != null)
                    {
                        System.debug('% '+contractListMap.get(oli.OpportunityId));
                        for(String s : contractListMap.get(oli.OpportunityId))
                        {
                            Contract_Product__c c = new Contract_Product__c();
                            System.debug('333333333333'+s);
                            c.Contract__c = s;
                            c.ServiceDate__c = oli.ServiceDate;
                            c.Discount__c = oli.Discount;
                            c.Description__c = oli.Description;
                            c.ListPrice__c = oli.ListPrice;
                            c.Opp_Line_Item_Id__c = oli.id;
                            c.Product__c = oli.Product2Id;
                            c.ProductCode__c = productMap.get(oli.Product2Id);
                            c.Quantity__c = oli.Quantity;
                            c.UnitPrice__c = oli.UnitPrice;
                            
                            contractProducts.add(c);
                        }
                    }
                }
                System.debug('++++++++++++'+contractProducts);
                if(contractProducts.size()>0)
                {
                    insert contractProducts;
                }
                System.debug('-------------- '+contractProducts);
            }
            
            // Block for update line items
            
            if(Trigger.isUpdate)
            {
                List<String> oppLineItemIds = new List<String>();
                List<String> unmatchedOppLineItemIds = new List<String>();
                for(OpportunityLineItem oli : Trigger.new)
                {
                    oppLineItemIds.add(oli.id);
                }
                
                List<Contract_Product__c> contractProdList = [select id, 
                                                                        Contract__c,
                                                                        ServiceDate__c,
                                                                        Discount__c,
                                                                        Description__c,
                                                                        ListPrice__c,
                                                                        Opp_Line_Item_Id__c,
                                                                        Product__c,
                                                                        ProductCode__c,
                                                                        Quantity__c,
                                                                        UnitPrice__c from Contract_Product__c 
                                                                        where Opp_Line_Item_Id__c in : oppLineItemIds ];
                
                
                delete contractProdList;
                
                for(OpportunityLineItem oli : Trigger.new)
                {
                    
                    if(contractListMap.get(oli.OpportunityId) != null)
                    {
                        System.debug('% '+contractListMap.get(oli.OpportunityId));
                        for(String s : contractListMap.get(oli.OpportunityId))
                        {
                            Contract_Product__c c = new Contract_Product__c();
                            System.debug('333333333333 update'+s);
                            c.Contract__c = s;
                            c.ServiceDate__c = oli.ServiceDate;
                            c.Discount__c = oli.Discount;
                            c.Description__c = oli.Description;
                            c.ListPrice__c = oli.ListPrice;
                            c.Opp_Line_Item_Id__c = oli.id;
                            c.Product__c = oli.Product2Id;
                            c.ProductCode__c = productMap.get(oli.Product2Id);
                            c.Quantity__c = oli.Quantity;
                            c.UnitPrice__c = oli.UnitPrice;
                            
                            contractProducts.add(c);
                        }
                    } 
public class ctrlJQDatePicker {
  public String dateDefaultValue { get;set; }
}
can any one write a test class for this?
thanks in advance