• KeithJ
  • NEWBIE
  • 150 Points
  • Member since 2008

  • Chatter
    Feed
  • 6
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 47
    Questions
  • 107
    Replies

 <apex:pageBlock title="Linked Equipments"> <apex:pageBlockTable value="{!Opportunity.Opportunity_Equipments__r}" var="item"> <apex:column value="{!item.Asset__r.Name}"/> <apex:column value="{!item.Asset__r.Description}"/> <apex:column value="{!item.Asset__r.UsageEndDate}"/> <apex:column value="{!item.Asset__r.SerialNumber}"/> <apex:column value="{!item.Asset__r.PurchaseDate}"/> </apex:pageBlockTable> </apex:pageBlock>

 

I have a page where user can relate Assets to Opportunity. After pressing "add" commandbutton I rerender the datatable that show currently related Assets. However the above markup does not seem to work and show new related Assets after rerender. I only got it working after writing my own getter method.

 

But is it possible to get it working using the std controller record collection ? (Opportunity.Opportunity_Equipments__r)

 

 

Thanks for help

  • February 15, 2009
  • Like
  • 0

Hi,

 

I need help in finding a solution of opening a Word Document from SControl.

Let me explain the scenario.

Word Document is uploaded as an Attachment to Salesforce system. 

 

Now my requirement is that when i click a View button in my Scontrol, i have to retrieve the content of Word Doc attachment and modify some values in that content.

Then this modified word doc content should be opened as a Word Document from the SControl.

 

So what should be done to achieve this.

 

Any help on this will be highly appreciated.

 

Thanks,

OnDem

Hi there. Im looking to create a customer portal user via the web services api.

 I see that any new user that is to be created my be associated with a userRole.

Now, I'm wondering how one could create a userRole?

 

I was thinking of populating the field portalAccountId but I checked the schema explorer and it's not createable...

I'm wondering what my other options are?

Thank you very much.

Hi there.

I have hit a brick wall.

I have an inputText that binds to a string in my controller.

Now, when the inputText is empty, the property String in my controller is set to nothing...empty.

Every single attempt to check the value is empty with if statements, will not work.

I cannot enter my block of code is the inputText value is empty.

The use case is that the inputText is given a value by the user, a value is added to a map.

If the user removes the value from the inputText field, I want to clear the map.

This seems so simple but wont work.

 

Here's the relevant portion of my code:

 

 

<apex:inputText value="{!catalogueEntryOne}" id="catalogueOne"> <apex:actionSupport event="onblur" action="{!retrieveCatalogueOneProduct}" rerender="ItemTableBlock" /> </apex:inputText> .... public String catalogueEntryOne { get; set {this.catalogueEntryOne = value; System.debug('***** CATALOGUE ENTRY ONE IS: ' + catalogueEntryOne); } } ... if(catalogueEntryOne != null) { for(Shop_Direct_Product__c shopProd : productList) { if(catalogueEntryOne.equals(shopProd.Name)) { if(!tableRecMap.containsKey(shopProd.Id)) { tableRecMap.put(shopProd.Id,new ProductTableRecord(false,shopProd)); tableRecList = tableRecMap.values(); this.cacheCatalogueEntryOne = String.valueOf(catalogueEntryOne); showTable = true; } } } }else if(catalogueEntryOne.length()==0){ System.debug('***** IN ELSE!!!!! *****'); //This is NEVER printed.

 

Any ideas?

I have tried various combinations. I have removed the else if(catalogueEntryOne.length()==0...

In the debug log when the inputText is cleared out and has not text, I see:


***Begining Page Log for /apex/OrderPage 20090616162304.004:Class.OrderPageExtension: line 9, column 100: ***** CATALOGUE ENTRY ONE IS: 20090616162304.004:External entry point: returning from end of method public void in 1 ms

 


 Please help!

 

Thanks

 

 

 

 

Hi there.

I have an inputField (of type date) on my visualforce page.

It is placed in a pageBlockSection which resides in a pageBlock.

 

Initially the pageBlock is not rendered.

When it is finally rendered (after another visualforce component calling a rerender on this pageBlock) the calendar popup will not show. If I move the offending inputField to another pageBlock which is always rendered, the popup calendar for the field will show up as normal.

 

Any suggested work arounds?

 

Thanks

Hi there. I have a commandLink which wraps around an apex param.

I have set the value and action attributes for the commandLink although a page redirect occurs.

I do not want this to happen.

The associated action method in my controller has a return type of PageReference but returns null, although

when I click the link a page redirect still occurs.

Is there a way to bypass the page redirect with a commandLink?

 

Thanks

Hi there.

I am using an apex repeat component inside an apex panelGrid component.

Unfortunately, I read that using an apex repeat within a panelGrid will just render

evertything in a single panel grid cell which is not what I want.

 

I am trying to find a way to display my content, 3 entities across and once past 3,

the next entity moves to a new line.

 

 

<apex:panelGrid columns="3" width="100%"> <apex:repeat value="{!dataList}" var="interviewEntry"> <apex:panelGroup> <div class="img"> <a href="{!interviewEntry.communityLink}" class="highlightit"> <img src="{!interviewEntry.intervieweeImage}" class="imgId" /> </a> <div class="desc"> <apex:outputText value="{!interviewEntry.intervieweeName}" style="font-weight: bold; font-family:Verdana,Arial,Helvetica,sans-serif; font-size: 75%;" /> </div> </div> </apex:panelGroup> </apex:repeat> </apex:panelGrid> </apex:page>

 

 

 


Any ideas?
Thanks

  • March 20, 2009
  • Like
  • 0

Hi there.

I'm sure this is a very trivial question,

but I'm trying to display an Image with text above it using PanelGrid and an embedded PanelGroup.

It wont work for me...

 

I can get the text to appear above the image but then each image & text is on it's own line.

Cannot figure how to get around this,...

 

Here's my vf code:

 

 

<apex:panelGrid columns="3" width="80%">
<apex:repeat value="{!dataList}" var="interviewEntry">
<apex:panelGroup>
<h2>test</h2>
<a href="{!interviewEntry.communityLink}" class="highlightit">
<img src="{!interviewEntry.intervieweeImage}" class="imgId" />
</a>
</apex:panelGroup>
</apex:repeat>
</apex:panelGrid>

 

What I get is

 

test

 ------

|       |

|       |

 ------

 

test2

 ------

|        |

|        |

 ------

 

 

etc

 

But I want:          test                test2

                         -------             ---------

                        |         |           |            |

                        |         |           |            |

                         -------             ---------

 

  • March 18, 2009
  • Like
  • 0

Hi there. Does anyone know how to do this?

In my visualforce code, I have 2 apex-repeat components.

The first one loops through a list of all the keys of a map M.

The second embedded apex-repeat loops through the value of the

Map M for the key of the outer repeat.

 

I'm having trouble trying to figure out how to do this because

I need to pass through to the controller, the current value of the key (outer most repeat).

 

Can figure it out! I tried using apex-outputText with an embedded param but it doesn't work for me.

 

Here's my controller code:

 

 

public Map<String,List<ChartRow>> chartDataMap { get; set; } //KeySet and Values are used in VisualForce page. public String keyStr { get; set { keyStr = value; System.debug('***** KEYSTR VALUE IS: ' + keyStr); } } public List<String> chartDataKeySet { get { List<String> keyList = new List<String>(); for(String s : chartDataMap.keySet()) keyList.add(s); return keyList; } set; } public List<ChartRow> chartRowRecord { get { System.debug('***** CHART ROW RECORD PROPERTY IS: ' + chartDataMap.get(keyStr)); return chartDataMap.get(keyStr); } set; }

 I want to set the property keyStr from the value of the outer apex-repeat

as in - 

 

 

<apex:repeat value="{!chartDataKeySet}" var="rigNatureVar"> <!-- the map key --> <!-- I want to set keyStr here so the following apex repeat will return the correct value from the map --> <apex:repeat value="{!chartRowRecord}" var="chartDataRecord"> <apex:outputText value="{!chartDataRecord}" /> </apex:repeat> </apex:repeat>

 

Many thanks.

 

 

 

 

  • March 13, 2009
  • Like
  • 0

Hi There. I'm wondering if anyone has ever received this error before?

I am completely bewildered by this one...

 

The error message states 

Argument 1 cannot be null

 

Here is my code that is giving me the problem:

 

 

private void constructBarWidths(Rig__c rigRec, List<Opportunity> rigOpportunities, List<Contract> rigContracts) { //For each Opportunity we need: //Opportunity name, stage, Contract Start date, Global End date if(rigOpportunities != null && rigOpportunities.size()>0) { for(Opportunity o : rigOpportunities) { if(o.Start_Date__c != null) {

 

 The error happens at the for loop.

I don't get it because I do a check on Argument 1 (aka rigOpportunities)  to make sure it is not null AND it's size is greater than 0...

Any ideas?

Thanks!

 

 

  • March 11, 2009
  • Like
  • 0

Hi there. I have done something similar before but it will not work now.

I cannot figure out for the life of me why not...

Hoping someone can help.

Ok, now, I have a controller. In the controller I have a wrapper class that has an opportunityLineItem.

Now, I can set this value no problem.

So, in my vf page, I cannot access any fields from this embedded opportunityLineItem.

Very bizare:

 

Here is the nested class in my controller:

 

public class CustomOppLineItem { public PricebookEntry pBookEntry { get; set; } public OpportunityLineItem oppLineItem { get; set; } public CustomOppLineItem(PricebookEntry pBookEntry, OpportunityLineItem oppLineItem) { this.pBookEntry = pBookEntry; this.oppLineItem = oppLineItem; } }

 And here is my visualforce section:

 

<apex:repeat value="{!customLineItemList}" var="currentOppLineItem" > <!-- Your field values here --> <tr style="font-size:75%;"> <td><apex:outputField value="{!currentOppLineItem.oppLineItem.PricebookEntry.Name}" /><br /> <span style="font-size:60%; font-weight:bold;">

 

 The error states:

 

 

Error: Unknown property 'CustomOppLineItem.PricebookEntry'

 

 

 

 

 

  • March 09, 2009
  • Like
  • 0

Hi.

Anyone know if you can do this? I am trying and it's giving me an error stating 

Error: Syntax error. Missing ')'

 Here is my outputField

 

 

value="{!CASE(currentOppLineItem.usdLineItem.Quote_Currency__c, '(NOK)', currentOppLineItem.nokLineItem.UnitPrice, '(EUR)', currentOppLineItem.eurLineItem.UnitPrice, currentOppLineItem.usdLineItem.UnitPrice)}"

 I have a sneaking suspicion this is not allowed...

Thanks

 

 


 

  • March 06, 2009
  • Like
  • 0

Hey there.

I'm trying to determine the best approach to something I'm about to build.

I'm looking to develop out some sort of Gantt chart -  What concerns me the most

is how to plot a start date and an end date against a set calendar (logically).

I could build out the calendar part fine - but any suggestions as to how I could

plot a coloured bar against a date from the start time to the end time:

 

Similar to the standard salesforce calendar:

 

 

I could create the calendar ok - but any suggestions for plotting a coloured bar based on a start date and end date?

Is there some sort of standard approach people adopt to this? This doesn't seem easy...

 

Thanks & Best regards

  • February 27, 2009
  • Like
  • 0

Hi there. I'm looking at the schema and wondering how a case is closed?

I see a non writeable field called is closed, but I cant see any (intuitive) child relationships from

case to another SObject that sets this value.

Does anyone know?

It's for a trigger I am writing.

Thanks!!

  • February 25, 2009
  • Like
  • 0

Hi there. I'm wondering if anybody in the past has merged 2 or more pdf files using the getContent()

method or something similar? Is this possible?

Thanks

  • February 24, 2009
  • Like
  • 0

Hi there. Is anyone aware how to capture linefeeds with <apex inputTextArea...

I have an inputTextArea that is bound to a String in my controller.

When I set this in the body of an email, there are no line feeds!

Any input appreciated,

Thanks

  • February 23, 2009
  • Like
  • 0

Anyone ever seen this before?

I get this error when trying to send a Messaging.SingleEmailMessage...

 

 

public void emailCVToContact(SystemContactRecord contactRecord, List<ID> attachmentIds, String fromEmailAddress, String candidateName) { Messaging.SingleEmailMessage singleCVEmail = new Messaging.SingleEmailMessage(); singleCVEmail.setReplyTo(fromEmailAddress); singleCVEmail.setSaveAsActivity(false); singleCVEmail.setSubject('Candidate CV : ' + candidateName); singleCVEmail.setDocumentAttachments(attachmentIds); singleCVEmail.setHtmlBody(' This is a test email'); singleCVEmail.setToAddresses(new String[]{contactRecord.con.Email}); //Now send the email try { List<Messaging.SendEmailResult> emailSendResults = Messaging.sendEmail(new Messaging.SingleEmailMessage[]{singleCVEmail}); //ERROR GENERATED HERE!! for(Messaging.SendEmailResult sentEmailResult : emailSendResults) { if(!sentEmailResult.isSuccess()) { //There was a problem sending the email, so print the error messages //to the system logs List<Messaging.SendEmailError> resultsErrors = sentEmailResult.getErrors(); if(resultsErrors.size() > 0) for(Messaging.SendEmailError sendMailError : resultsErrors) System.debug('***** SEND EMAIL ERROR MESSAGE: ' + sendMailError.getMessage()); } //else sent successfully regardless of post problems else { //break out of loop - only single email enabled numberOfEmailsActuallySent++; break; }//close else }//close for }catch(EmailException ee) { System.debug('***** THERE WAS AN ISSUE SEND THE QUOTE TO THE DESTINATION EMAIL: ' + ee.getMessage()); } }

 

 I've never seen this before...

Any info appreciated!

Thanks

 

  • February 22, 2009
  • Like
  • 0

Hi there. When creating an instance of EmailFileAttachment, can you call setBody with an argument of

.doc? I.e a word file? I would imagine not as it's a binary file. But, if there is an alternative - is anybody aware

if you can even send an email with a .doc attachment?

Thanks!

  • February 20, 2009
  • Like
  • 0

Hi there. Does anyone have any suggestions for saving a List state of a controller?

Here's the scenario. Im trying to create a wizard like app. Page 1 has a list of Contacts (contactList)

of which a table is generated. There is a next button on page 1 that returns a pagereference to Page 2.

When a certain button is clicked on Page 2, I want to write to the database the values that were set in the contact list (contactList)

in the controller of Page 1. Is this possible - will the transient keyword help me out here?

 

Many thanks.

Regards

  • February 19, 2009
  • Like
  • 0

Hi there. Is anyone aware of a way to refresh an opportunity detail page from a visual force page?

I have a standard opportunity detail page that when you click a button, it opens a visual force page in its own window.

When a button is clicked I want to refresh the opportunity detail page from the visual force page.

Is this possible?

Thanks!

  • February 15, 2009
  • Like
  • 0

Hi there. Is it possible to set an attachment for a Messaging.MassEmailMessage object?

I hope so!

Thanks

  • February 15, 2009
  • Like
  • 0

Hi there.

Does anyone have any tips for setting the ownerId of a new Idea

when created from a site?

 

I have a vf page that captures data using inputText fields and sets values in

an Idea (newly instantiated) in the code and then inserts this. The reason 

I have to do it this way is because ideas are read only when exposed with sites

Thanks

  • February 05, 2009
  • Like
  • 0
Hi there. I have the following code that leverages a custom object called "Test__c", that has
1 field, which is a lookup to Accounts.

Code:
<apex:page standardController="Test__c" tabStyle="Test__c">
    <apex:sectionHeader title="{!$ObjectType.Test__c.label} Edit" subtitle="New Test"/>
    <apex:form>
    <apex:pageBlock title="Test">
        <apex:pageBlockButtons>
            <apex:commandButton value="Save" action="{!save}" />
            <apex:commandButton value="Cancel" action="{!cancel}" />
        </apex:pageBlockButtons>
    <apex:actionRegion>
        <apex:pageBlockSection title="Information">
            <apex:inputField value="{!Test__c.Account__c}">
                <apex:actionSupport event="onselect" rerender="otherPanel" />
            </apex:inputField>
        </apex:pageBlockSection> 
    </apex:actionRegion>  
    
    <apex:pageBlockSection title="test" id="otherPanel" rendered="true">
        <apex:outputField value="{!Test__c.Account__c}" />
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Now, when I type a value into the lookup box and I select a value from the autocomplete, the value in the "test" pageBlockSection will update in an Ajax fashion like so:
 

But when I use the lookup dialog to select an account, the field will not update:


Any ideas??
Thanks
  • December 10, 2008
  • Like
  • 1

Hi All,

          I am trying to retrieve a picklist value from page to control. In the control, I am getting the field value id and not the field value text. And i am retrieving using property fields like public String selecteduser{set;get;}.I need to use that retrieved value in a where clause of an query. Please tell me how can i get the picklist text value?

 

 Tons of Thanks,

  Nishanth.

 

Hi,

 

Iam  new to Apex.I have  custom objects Order and Order Line Items (master detail).The order line items appears as a related list under the Order object.

 

Whenever an order is created from the quote,the quoteline items should be inserted as order line items ....This functionality is just like how the opportunity products are inserted as quote line items whenever a new quote is created from the opportunity.

 

Is it possible to do this using a trigger?

 

If yes ,can i please have some pointers to any sample trigger code that does this kind of insert from a related list of the master object to the related list of the detail object

 

Thanks!

Hi All,

 

Does anyone know how to use create visualforce page that load google map and represent a list of account using the marker?

 

Thanks

 

Hi there.

I have hit a brick wall.

I have an inputText that binds to a string in my controller.

Now, when the inputText is empty, the property String in my controller is set to nothing...empty.

Every single attempt to check the value is empty with if statements, will not work.

I cannot enter my block of code is the inputText value is empty.

The use case is that the inputText is given a value by the user, a value is added to a map.

If the user removes the value from the inputText field, I want to clear the map.

This seems so simple but wont work.

 

Here's the relevant portion of my code:

 

 

<apex:inputText value="{!catalogueEntryOne}" id="catalogueOne"> <apex:actionSupport event="onblur" action="{!retrieveCatalogueOneProduct}" rerender="ItemTableBlock" /> </apex:inputText> .... public String catalogueEntryOne { get; set {this.catalogueEntryOne = value; System.debug('***** CATALOGUE ENTRY ONE IS: ' + catalogueEntryOne); } } ... if(catalogueEntryOne != null) { for(Shop_Direct_Product__c shopProd : productList) { if(catalogueEntryOne.equals(shopProd.Name)) { if(!tableRecMap.containsKey(shopProd.Id)) { tableRecMap.put(shopProd.Id,new ProductTableRecord(false,shopProd)); tableRecList = tableRecMap.values(); this.cacheCatalogueEntryOne = String.valueOf(catalogueEntryOne); showTable = true; } } } }else if(catalogueEntryOne.length()==0){ System.debug('***** IN ELSE!!!!! *****'); //This is NEVER printed.

 

Any ideas?

I have tried various combinations. I have removed the else if(catalogueEntryOne.length()==0...

In the debug log when the inputText is cleared out and has not text, I see:


***Begining Page Log for /apex/OrderPage 20090616162304.004:Class.OrderPageExtension: line 9, column 100: ***** CATALOGUE ENTRY ONE IS: 20090616162304.004:External entry point: returning from end of method public void in 1 ms

 


 Please help!

 

Thanks

 

 

 

 

Hi there.

I have an inputField (of type date) on my visualforce page.

It is placed in a pageBlockSection which resides in a pageBlock.

 

Initially the pageBlock is not rendered.

When it is finally rendered (after another visualforce component calling a rerender on this pageBlock) the calendar popup will not show. If I move the offending inputField to another pageBlock which is always rendered, the popup calendar for the field will show up as normal.

 

Any suggested work arounds?

 

Thanks

Hi there. I have a commandLink which wraps around an apex param.

I have set the value and action attributes for the commandLink although a page redirect occurs.

I do not want this to happen.

The associated action method in my controller has a return type of PageReference but returns null, although

when I click the link a page redirect still occurs.

Is there a way to bypass the page redirect with a commandLink?

 

Thanks

How can I write a visual page which list all the records that I have on custom object called Hotel with check box next to each record.

 

So for instance, the display will look like below

 

check box  hotelid1 hotel name1 

check box  hotelid2 hotel name2

check box  hotelid3 hotel name3

check box  hotelid4 hotel name4

check box  hotelid5 hotel name 5

etc

 

I do hope it makes sense and I would extremely appreiciate if someone can let me know wheather it is possible or not.

 

Regards, 

  • May 13, 2009
  • Like
  • 0

Hi there.

I am using an apex repeat component inside an apex panelGrid component.

Unfortunately, I read that using an apex repeat within a panelGrid will just render

evertything in a single panel grid cell which is not what I want.

 

I am trying to find a way to display my content, 3 entities across and once past 3,

the next entity moves to a new line.

 

 

<apex:panelGrid columns="3" width="100%"> <apex:repeat value="{!dataList}" var="interviewEntry"> <apex:panelGroup> <div class="img"> <a href="{!interviewEntry.communityLink}" class="highlightit"> <img src="{!interviewEntry.intervieweeImage}" class="imgId" /> </a> <div class="desc"> <apex:outputText value="{!interviewEntry.intervieweeName}" style="font-weight: bold; font-family:Verdana,Arial,Helvetica,sans-serif; font-size: 75%;" /> </div> </div> </apex:panelGroup> </apex:repeat> </apex:panelGrid> </apex:page>

 

 

 


Any ideas?
Thanks

  • March 20, 2009
  • Like
  • 0

Hi there. Does anyone know how to do this?

In my visualforce code, I have 2 apex-repeat components.

The first one loops through a list of all the keys of a map M.

The second embedded apex-repeat loops through the value of the

Map M for the key of the outer repeat.

 

I'm having trouble trying to figure out how to do this because

I need to pass through to the controller, the current value of the key (outer most repeat).

 

Can figure it out! I tried using apex-outputText with an embedded param but it doesn't work for me.

 

Here's my controller code:

 

 

public Map<String,List<ChartRow>> chartDataMap { get; set; } //KeySet and Values are used in VisualForce page. public String keyStr { get; set { keyStr = value; System.debug('***** KEYSTR VALUE IS: ' + keyStr); } } public List<String> chartDataKeySet { get { List<String> keyList = new List<String>(); for(String s : chartDataMap.keySet()) keyList.add(s); return keyList; } set; } public List<ChartRow> chartRowRecord { get { System.debug('***** CHART ROW RECORD PROPERTY IS: ' + chartDataMap.get(keyStr)); return chartDataMap.get(keyStr); } set; }

 I want to set the property keyStr from the value of the outer apex-repeat

as in - 

 

 

<apex:repeat value="{!chartDataKeySet}" var="rigNatureVar"> <!-- the map key --> <!-- I want to set keyStr here so the following apex repeat will return the correct value from the map --> <apex:repeat value="{!chartRowRecord}" var="chartDataRecord"> <apex:outputText value="{!chartDataRecord}" /> </apex:repeat> </apex:repeat>

 

Many thanks.

 

 

 

 

  • March 13, 2009
  • Like
  • 0

Hi There. I'm wondering if anyone has ever received this error before?

I am completely bewildered by this one...

 

The error message states 

Argument 1 cannot be null

 

Here is my code that is giving me the problem:

 

 

private void constructBarWidths(Rig__c rigRec, List<Opportunity> rigOpportunities, List<Contract> rigContracts) { //For each Opportunity we need: //Opportunity name, stage, Contract Start date, Global End date if(rigOpportunities != null && rigOpportunities.size()>0) { for(Opportunity o : rigOpportunities) { if(o.Start_Date__c != null) {

 

 The error happens at the for loop.

I don't get it because I do a check on Argument 1 (aka rigOpportunities)  to make sure it is not null AND it's size is greater than 0...

Any ideas?

Thanks!

 

 

  • March 11, 2009
  • Like
  • 0

Hi.

Anyone know if you can do this? I am trying and it's giving me an error stating 

Error: Syntax error. Missing ')'

 Here is my outputField

 

 

value="{!CASE(currentOppLineItem.usdLineItem.Quote_Currency__c, '(NOK)', currentOppLineItem.nokLineItem.UnitPrice, '(EUR)', currentOppLineItem.eurLineItem.UnitPrice, currentOppLineItem.usdLineItem.UnitPrice)}"

 I have a sneaking suspicion this is not allowed...

Thanks

 

 


 

  • March 06, 2009
  • Like
  • 0
Hi there.
I have the following apex class that is to send an email which includes
a visualforce email template.
Unfortunately when I include setTemplateID method that
has a parameter of the exact VF email template I want to send,
I get false. Everytime. If I remove the setTemplateID, I get an email,
minus my template.
Can anyone help me out please?
Here is my apex class
 
public class EmailCardListController {
 
public Boolean emailSent { get; set; }
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'jbloggs@salesforce.com'};
 
    public PageReference sendMail() {
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('jbloggs@salesforce.com');
        mail.setSenderDisplayName('Salesforce Support');
        mail.setSubject('New Case Created : ' + case.Id);
        mail.setUseSignature(false);
        mail.setTemplateId('00X200000015XFL');
        try {
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });   
            emailSent = true;
            return null;
        }catch(Exception e) {
             System.debug(e.getMessage());
             emailSent = false;
             return null;
        }
    }
}
 
And here is my Template;
<messaging:emailTemplate subject="Christmas Card List" recipientType="User" relatedToType="AccountTag" rendered="true">
    <messaging:htmlEmailBody >
     <p> please work! </p>
    </messaging:htmlEmailBody>
   <messaging:attachment fileName="cardList.csv">
         <c:cardList />
   </messaging:attachment>
</messaging:emailTemplate>
 
The custom component cardList is:
<apex:component controller="ChristmasCardController" access="global">
    <apex:repeat var="taggedAccount" value="{!taggedAccountsInformation}" >
        {!taggedAccount.Name}, {!taggedAccount.BillingStreet}, {!taggedAccount.BillingCity}, {!taggedAccount.BillingPostalCode}, {!taggedAccount.BillingState}, {!taggedAccount.BillingCountry}
    </apex:repeat>
</apex:component>
 
I know the custom component works, because I have tested it within a visual force page.
Please, Please can you help? Thank you very much
  • November 28, 2008
  • Like
  • 0