Skip to main content
Added sample code
Source Link
McB
  • 131
  • 6

I've got a custom object "Invoices" tied to my Opportunities, so Opps have 1 or more invoices. Each invoice has a "date to be sent" field.

What I'd like to do is auto-generate an email every Monday morning that notifies each User of their Opportunities and with Invoices scheduled to go out < Next 7 Days. The purpose is for them to go in and edit the Invoice to either flag is as "Ok to send" or to move the date back to a more appropriate time.

I'm trying to accomplish this using a VisualForce email template, but can't for the life of my figure out if the relatedTo should = User or Opportunity since I want it to list all of the relevant invoices for Opportunities owned by the User.

Anyone have any guidance on how best to implement something like this?

Adding in some code from VF Email.


messaging:emailTemplate subject="Review Invoices" recipientType="User" relatedToType="Opportunity"    

//then the loop for invoices
apex:repeat var="cx" value="{!relatedTo.Invoice__c}"

//show this stuff in a table. Can use outputtext to skip if date is out of range
{!relatedTo.name}
{!cx.Invoice_name__c}
{!cx.Invoice_amount__c}

/apex:repeat

This code isn't finding the invoice__c object, and I've tried all kinds of variations. Can't seem to find an easy reference for how object elements relate via API name anywhere.

I've got a custom object "Invoices" tied to my Opportunities, so Opps have 1 or more invoices. Each invoice has a "date to be sent" field.

What I'd like to do is auto-generate an email every Monday morning that notifies each User of their Opportunities and with Invoices scheduled to go out < Next 7 Days. The purpose is for them to go in and edit the Invoice to either flag is as "Ok to send" or to move the date back to a more appropriate time.

I'm trying to accomplish this using a VisualForce email template, but can't for the life of my figure out if the relatedTo should = User or Opportunity since I want it to list all of the relevant invoices for Opportunities owned by the User.

Anyone have any guidance on how best to implement something like this?

I've got a custom object "Invoices" tied to my Opportunities, so Opps have 1 or more invoices. Each invoice has a "date to be sent" field.

What I'd like to do is auto-generate an email every Monday morning that notifies each User of their Opportunities and with Invoices scheduled to go out < Next 7 Days. The purpose is for them to go in and edit the Invoice to either flag is as "Ok to send" or to move the date back to a more appropriate time.

I'm trying to accomplish this using a VisualForce email template, but can't for the life of my figure out if the relatedTo should = User or Opportunity since I want it to list all of the relevant invoices for Opportunities owned by the User.

Anyone have any guidance on how best to implement something like this?

Adding in some code from VF Email.


messaging:emailTemplate subject="Review Invoices" recipientType="User" relatedToType="Opportunity"    

//then the loop for invoices
apex:repeat var="cx" value="{!relatedTo.Invoice__c}"

//show this stuff in a table. Can use outputtext to skip if date is out of range
{!relatedTo.name}
{!cx.Invoice_name__c}
{!cx.Invoice_amount__c}

/apex:repeat

This code isn't finding the invoice__c object, and I've tried all kinds of variations. Can't seem to find an easy reference for how object elements relate via API name anywhere.

Source Link
McB
  • 131
  • 6

Generate a weekly email for each user based on role, who have custom opportunity objects that meet a criteria

I've got a custom object "Invoices" tied to my Opportunities, so Opps have 1 or more invoices. Each invoice has a "date to be sent" field.

What I'd like to do is auto-generate an email every Monday morning that notifies each User of their Opportunities and with Invoices scheduled to go out < Next 7 Days. The purpose is for them to go in and edit the Invoice to either flag is as "Ok to send" or to move the date back to a more appropriate time.

I'm trying to accomplish this using a VisualForce email template, but can't for the life of my figure out if the relatedTo should = User or Opportunity since I want it to list all of the relevant invoices for Opportunities owned by the User.

Anyone have any guidance on how best to implement something like this?