function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vijay jillella 9vijay jillella 9 

auto number is not displaying in attachment

please help me withthe below
My concern is while i am generating an invoice and returning page i am able to see the invoice number in the page and when i am attaching it invoice number is missing.
here is the code
public SpecialInvoicesGST_vijay(){
//wrapObj = new list<ContactWrapper>();
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';//
 System.debug('rrrrrr'+val);
 inv = [SELECT id,Name,Invoice_Date__c  FROM Invoice__c ORDER BY Name DESC LIMIT 1]; //
  String s1= inv.Name;//
   invNo = Long.valueOf( s1.substring(3));//
  system.debug('&&invNo&&'+invNo);
}  
public void attachPdfToAccount(String  invBillCalendar, String appointmentEmployer, id invId){
     
Billing_Calendar__c bc=new Billing_Calendar__c(); 
bc=[select id,Name, Invoicing_Start_Date__c,Invoicing_End_Date__c from Billing_Calendar__c where Billing_Calendar__c.id=:invBillCalendar limit 1];            
Account acc = [select id,Name from Account where ID=:appointmentEmployer];    
if(ep=='None'&& desp==null)
{this.ep=desp;}
else{this.ep=ep;}
finalAcc = getAcc();
pagereference ref1;

//=================================main part to work===================================================//
   
Attachment myAttach1 = new Attachment();
flag = 'attach';
myAttach1.ParentId = invid;
inm3= [SELECT id,Name,invoiceNamecopy__C,invcopyno__C,Invoice_Date__c  FROM Invoice__c Where Id =: invId];
//myAttach1.name =bc.Invoicing_Start_Date__c+'To'+bc.Invoicing_End_Date__c +'.pdf';
myAttach1.name =inm3.name+'.pdf';
    
//myAttach1.body= ref.getContentAsPdf();

//myattach1.Id=inm1.id;
                       
if(appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirW')
{
//ref=page.Tesco_Special_Invoice_GST1;
   // ref=page.Tesco_Invoice;
     ref1=page.Tesco_Special_Invoice_GST_vijay;
}
else if(appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirY') 
{
//ref=page.Wipro_Special_Invoice_GST;
ref1=page.Wipro_Special_Invoice_GST_vijay;
system.debug('wipro special invoice');
}
else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJira') )
{
//ref=page.IBM_Special_Invoice_GST1;
ref1=page.IBM_Special_Invoice_GST1_vijay; 
}
else if (appointment1.SCSCHAMPS__Employer__c=='0010k00000T2XXC')
{
ref1=page.testspecial;
}
/*else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirY') && (toi=='Allowances'))
{
ref=page.Wipro_Invoice_Allowances;
 }*/
else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPRC')
{

ref1=page.First_American_Special_Invoice_GST;

}
else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirS')
{
//ref=page.SAP_Labs_Special_Invoice_GST;
ref1=page.SAP_Labs_Special_Invoice_GST_vijay;
}
else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPLG')
{
//ref=page.BNP_SIGST_Production;
ref1=page.BNP_SIGST_Production_vijay;    
}
else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPKh')
{
//ref=page.Amdocs_Special_Invoice_GST;
ref1=page.Amdocs_Special_Invoice_GST_vijay;
}
else if (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJirU')
{
//ref=page.True_Blue_Special_Invoice_GST;
    ref1=page.True_Blue_Special_Invoice_GST_vijay;
}
else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001tJPSe') )
{
//ref=page.GenpactSpecialInvoiceGST;
ref1=page.GenpactSpecialInvoiceGST_vijay;             
}
else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001sbvvM') )
{
//ref=page.Special_Invoice_GSTAccenture_updated;  
ref1=page.Special_Invoice_GSTAccenture_vijay;           
}
else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00001yyxQS') )
{
//ref=page.Experis_IT_Special_invoice;   
ref1=page.Experis_IT_Special_invoice_vijay;          
}
else if( (appointment1.SCSCHAMPS__Employer__c=='0016F00002Ca81c') )
{
//ref=page.SAP_Premium_special_invoice_GST; 
 ref1=page.SAP_Premium_special_invoice_GST_vijay;             
}
else
{
ref1 = page.Consolidated_Special_Invoice_GST;
}
          
                
ref1.getParameters().put('inm3.name',inm3.name);

               
ref1.getParameters().put('accId',invId);
ref1.getParameters().put('flag1',String.valueOf(flag));
ref1.getParameters().put('ep1',ep);
ref1.getParameters().put('toi1',toi);
ref1.getParameters().put('stax1',stax);
ref1.getParameters().put('scurr1',scurr);
ref1.getParameters().put('pos',pos);
ref1.getParameters().put('sop1',sop);
ref1.getParameters().put('ids',strids);
                
                //GST Implementation
ref1.getParameters().put('taxa1',taxa);
ref1.getParameters().put('addG1',addG);
ref1.getParameters().put('gst1',gst);
            
ref1.getParameters().put('startDate',string.valueOf(bc.Invoicing_Start_Date__c));
ref1.getParameters().put('endDate',string.valueOf(bc.Invoicing_End_Date__c));
             
if(edate!=null)
ref1.getParameters().put('edt',string.valueOf(edate));
else 
ref1.getParameters().put('edt',string.valueOf(Date.Today())); 
if(bdate!=null)
ref1.getParameters().put('bdt',string.valueOf(bdate));
else 
ref1.getParameters().put('bdt',string.valueOf(Date.Today())); 
//ref1.getParameters().put('','print');  
   // ref1.getParameters().put('flag1','print');  
 myAttach1.body = ref1.getContentAsPdf();    
insert myAttach1;
attach();
}


vf page:
<apex:page Controller="SpecialInvoicesGST_vijay"  showHeader="false"  applyHtmlTag="false" renderAs="pdf" applyBodyTag="false" >
<html style="margin-top: 0px;font-size:10px;page-break-inside:avoid">
<head>
<style type="text/css" media="print">
@page {
 margin-top: 35mm;
  margin-bottom: 15mm;
@top-center {
content: element(header);
}
@bottom-left {
 content: element(footer);
}
}
</style>
</head>
 
<div class="header">
<div></div>
</div>
 
<div class="footer">
<div></div>
</div>
<body>
<div class="content">        
<table width="100%" cellspacing="0" cellpading="0" border="1" style="font-size:10px;page-break-inside:avoid" >
<tr><th colspan="9" bgcolor="#D3D3D3" align="center" ><h><span style="font-size:13px"><B>INVOICE---{!record.name}</B><br/> </span></h></th></tr>
<tr><apex:panelGroup rendered="{!taxa!='GST'}"><td height="50%" colspan="4"><h>To</h><br/><br/>
{!acc.BillingStreet}<br/>{!acc.BillingCity}<br/>{!acc.BillingState}&nbsp;{!acc.BillingPostalCode}<br/>{!acc.BillingCountry}&nbsp;{!acc.BillingLatitude}&nbsp;{!acc.BillingLongitude}                   

    </td>
</apex:panelGroup>
<apex:panelGroup rendered="{!taxa=='GST'}">
<td height="50%" colspan="4" style="display:{!if(addG=='GST1','','none')}" >To,
<br/>{!acc.GST1_Address__c}
<br/>{!acc.GST1_Street__c}
<br/>{!acc.GST1_City__c}
<br/>{!acc.GST1_State_Province__c}
<br/>{!acc.GST1_Zip_Postal_Code__c}
<br/>{!acc.GST1_Country__c}
<br/>GSTIN - {!acc.Client_GST1_Number__c}

</td>
<td height="50%" colspan="4" style="display:{!if(addG=='GST2','','none')}">To,
<br/>{!acc.GST2_Address__c}
<br/>{!acc.GST2_Street__c}
<br/>{!acc.GST2_City__c}
<br/>{!acc.GST2_State_Province__c}
<br/>{!acc.GST2_Zip_Postal_Code__c}
<br/>{!acc.GST2_Country__c}
<br/>GSTIN - {!acc.Client_GST2_Number__c}
</td>
<td height="50%" colspan="4" style="display:{!if(addG=='GST3','','none')}">To,
<br/>{!acc.GST3_Address__c}
<br/>{!acc.GST3_Street__c}
<br/>{!acc.GST3_City__c}
<br/>{!acc.GST3_State_Province__c}
<br/>{!acc.GST3_Zip_Postal_Code__c}
<br/>{!acc.GST3_Country__c}
<br/>GSTIN - {!acc.Client_GST3_Number__c}
</td>
</apex:panelGroup>
    
    <td height="50%" colspan="5">
<apex:variable value="{!Inm3.name}" var="inm"/> 


<apex:panelGroup >    
<h align="right" style="display:{!if(flag=='attach','{!inm}','{!inm}')}">
Invoice&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;11===={!record.name}<br/></h> 
<h align="right" style="display:{!if(flag=='false','','{!inm}')}">  
Invoice&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;21===={!inm}<br/></h>
<h align="right" style="display:{!if(flag=='print','','none')}">
Invoice&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;31===={!inm1}<br/></h>
<h align="right" style="display:{!if(flag=='view','','none')}">
Invoice&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;41===={!inm1}<br/></h>
</apex:panelGroup>
  <apex:pageBlock>
      <apex:pageBlockTable value="{!record}" var="a">
          <apex:column value="{!record.name}" title="iiiiiiiiiiiii"/>
      
      </apex:pageBlockTable>
        
        </apex:pageBlock