0

I'm trying to create a csv file attached to a visualforce email template. The csv file is based on a report that has a bunch of columns (fields) already, and all that I usually do is pass the Quote ID and the report fills in the line items.

I've tried the below and it generates the report in a CSV but with no data.

Visualforce Email Template Attachment

<messaging:attachment filename="{!relatedTo.Name}-{!relatedTo.EmailPDFName__c}.csv" > 
<c:QuoteCSV xtheQuoteID="{!relatedTo.Id}" />
</messaging:attachment>

Visualforce Component

<apex:attribute name="xtheQuoteID" description="quote ID" type="String" assignTo="{!theQuoteID}"/>

<apex:outputText value="{!CSVStream}" escape="false"/> 
</apex:component>

Apex Controller NOTE: I tried to re-engineer from another process

public class QuoteLineEmailController {

  public static Boolean isTest;
  public static String strOut = '';
  public String theQuoteID{get;set;}

  public void CSVStream () {
   strOut = '';
  }

  public String getCSVStream() {
    executeRpt();
    return strOut;
    }

   public void executeRpt() {
    String requestURL;
    requestURL = '/00OF0000005ueLL?xf=localecvs&export=&pv0=' + theQuoteID + '?csv=1&exp=1';
    strOut = Test.isRunningTest() ? 'test' : new PageReference(requestURL).getContent().toString();
    System.debug('CALLING executeRpt:  output= ' + strOut );
   }
 }

1 Answer 1

0

Scrapped the component section and utilized a simple query in the component to grab the following fields.

Created a new format of VisualForce component:

<apex:component controller="QuoteLineEmailController" access="global">
Opportunity ID Number,ORDER_NUMBER,PRODUCT_NUMBER,QUANTITY,PRICE_LIST_NAME,PRICE_MODF_NAME,PRICE_MODF_NUMBER,UNIT_PRICE,USER_DESCRIPTION 
<apex:attribute name="theQuoteID" type="Id" description="Id of the Quote" assignTo="{!QuoteID}"/>
    <apex:repeat var="CSVQLI" value="{!CSVQuoteLines}" >
            <apex:variable value="{!Quotee}" var="Q">
                {!Q.Opportunity_ID_Number__c}</apex:variable>,{!CSVQLI.Order_Number__c},{!CSVQLI.SBQQ__ProductCode__c},{!CSVQLI.SBQQ__Quantity__c},{!CSVQLI.Price_List_Name__c},{!CSVQLI.PRICE_MODF_NAME2__c},{!CSVQLI.PRICE_MODF_NUMBER2__c},{!CSVQLI.Internal_Discount__c},{!CSVQLI.User_Description__c}
    </apex:repeat>
</apex:component>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .