+ Start a Discussion
employAstar 5employAstar 5 

auto number feild value is not displayed when attached as PDF

constructor:
public GSTOrginal(){appointment1 = new SCSCHAMPS__Appointment__c();appde= new SCSCHAMPS__Appointment__c();
invBill=new Invoice__c();
invfp = new Invoice__c();
totall = 0;
contactList  = new List<ContactWrapper>();
 cb=false;
 flag='false';
 AppList = new List<AppWrap>();
 addMore();
 selectedRowIndex = '0';
 inv = [SELECT id,Name,Invoice_Date__c  FROM Invoice__c ORDER BY Name DESC LIMIT 1];
  String s1= inv.Name;
  invNo = (Long)Long.valueOf( s1.substring(3));
return page method:
 ref.getParameters().put('flag1',String.valueOf(flag));
            ref.getParameters().put('ids',strids);
            ref.getParameters().put('ep1',ep);
            ref.getParameters().put('toi1',toi);
            ref.getParameters().put('stax1',stax);
            ref.getParameters().put('scurr1',scurr);
            ref.getParameters().put('pos',pos);
            ref.getParameters().put('sop1',sop);
            ref.getParameters().put('accId',appointment.SCSCHAMPS__Employer__c);
            ref.getParameters().put('startDate',string.valueOf(bc.Invoicing_Start_Date__c));
            system.debug('bc.Invoicing_Start_Date__c'+bc.Invoicing_Start_Date__c);
            ref.getParameters().put('endDate',string.valueOf(bc.Invoicing_End_Date__c));
            system.debug('bc.Invoicing_End_Date__c'+bc.Invoicing_End_Date__c);
            
            //GST Implementation
            ref.getParameters().put('taxa1',taxa);
            ref.getParameters().put('addG1',addG);
            ref.getParameters().put('gst1',gst);
          
            if(edate!=null)
             ref.getParameters().put('edt',string.valueOf(edate));
            else 
             ref.getParameters().put('edt',string.valueOf(Date.Today()));
             if(bdate!=null)
             ref.getParameters().put('bdt',string.valueOf(bdate));
            else 
             ref.getParameters().put('bdt',string.valueOf(Date.Today()));  
            ref.setRedirect(false); 
            english_number();
            this.myList =myList ; 
                 List<Invoice__c>  inm2= [SELECT id,Name,Invoice_Date__c  FROM Invoice__c Where Id =: inv.id LIMIT 1];
            AppList[0].Invp=inm2[0];    } 
     attachPdfToAccount( invBill.Billing_Calendar__c, appointment.SCSCHAMPS__Employer__c,inv.id);      
       flag = 'attach';          
        return ref;                
}
attacgment method
public void attachPdfToAccount(String  invBillCalendar, String appointmentEmployer, String invId){  
Attachment myAttach1 = new Attachment();
                flag = 'attach';
                myAttach1.ParentId = invId;
                inm1= database.query('SELECT id,Name,Invoice_Date__c  FROM Invoice__c Where Id =: invId'); 
                myAttach1.name =inm1.name +'.pdf';
               //ref = page.Consolidated_Special_Invoice;

         if(appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirW')
            {
            ref=page.Tesco_Special_Invoice_GST;
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirY') )
            {
            ref=page.Wipro_Special_Invoice_GST;
             system.debug('wipro special invoice');
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJira') )
            {
            ref=page.IBM_Special_Invoice_GST;
             
            }
          
            else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPRC')
            {
          //  ref=page.First_American_Special_Invoice_GST;
         ref=page.FAGSTVFPORGINAL;
            }
            else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirS')
            {
            ref=page.SAP_Labs_Special_Invoice_GST;
            }
            else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPLG')
            {
            ref=page.BNP_Paribas_Special_Invoice_GST;
            }
            else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPKh')
            {
            ref=page.Amdocs_Special_Invoice_GST;
            }
            else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirU')
            {
            ref=page.True_Blue_Special_Invoice_GST;
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPSe') )
            {
            ref=page.GenpactSpecialInvoiceGST;             
            }
             else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001sbvvM') )
            {
            ref=page.Special_Invoice_GSTAccenture_updated;             
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001yyxQS') )
            {
            ref=page.Experis_IT_Special_invoice;             
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00002Ca81c') )
            {
            ref=page.SAP_Premium_special_invoice_GST;             
            }
            else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00002HFdk7') )
            {
            ref=page.SAP_education_special_invoice_gst;             
            }
            else
            {
            ref = page.Consolidated_Special_Invoice_GST;}
               
               ref.getParameters().put('inm1',String.ValueOf(inm1.Name));
                ref.getParameters().put('accId',acc.Id);
                ref.getParameters().put('flag1',String.valueOf(flag));
                ref.getParameters().put('ep1',ep);
                ref.getParameters().put('toi1',toi);
                ref.getParameters().put('stax1',stax);
                ref.getParameters().put('scurr1',scurr);
                ref.getParameters().put('pos',pos);
                ref.getParameters().put('sop1',sop);
                ref.getParameters().put('ids',strids);
                
                //GST Implementation
                ref.getParameters().put('taxa1',taxa);
                ref.getParameters().put('addG1',addG);
                ref.getParameters().put('gst1',gst);
            
                ref.getParameters().put('startDate',string.valueOf(bc.Invoicing_Start_Date__c));
                ref.getParameters().put('endDate',string.valueOf(bc.Invoicing_End_Date__c));
                
                if(edate!=null)
                ref.getParameters().put('edt',string.valueOf(edate));
                else 
                ref.getParameters().put('edt',string.valueOf(Date.Today())); 
                if(bdate!=null)
             ref.getParameters().put('bdt',string.valueOf(bdate));
            else 
             ref.getParameters().put('bdt',string.valueOf(Date.Today())); 
               ref.setRedirect(false);
                //myAttach1.body = ref.getContentAsPDF();    
               
               //ref.getParameters().put('flag1','print');
               Blob body;
               
                try {

          // returns the output of the page as a PDF
             body = ref.getContent();
             

            // need to pass unit test -- current bug    
             } catch (VisualforceException e) {
            body = Blob.valueOf('Some Text');
         }
          myAttach1.body=body;
          myAttach1.IsPrivate = false;
         insert myAttach1;
         
            }
         
}
page to input  invoice values
page to output for relevant account