You need to sign in to do that
Don't have an account?
Michael M
Schedule VF template to send once a month, only for specific users
Hello, we have a VF email template. We need to send this out automatically once a month, with a few conditions:
1) It must ONLY send to users that own at least 1 Lead record
2) It must only send ONE email to each of those users
3) it must send once a month (as mentioned)
If it is helpful, here are the details of my VF email. (I am using a component and controller)
VF TEMPLATE
<messaging:emailTemplate subject="Your Team's Leads- Owner Assignments" recipientType="User" relatedToType="User">
<messaging:htmlEmailBody >
Hi {!RelatedTo.firstName},
<p>The following leads have not yet been updated:</p>
<c:leadsinfo ToID="{!RelatedTo.Id}" />
<p>To update these leads, click on the "Lead Status" field located in the upper right on the lead page layout.</p>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
COMPONENT
<apex:component controller="LeadsInfoController" access="global">
<apex:attribute name="ToID" type="ID" description="the lead owner ID" assignTo="{!salesRepID}"/>
<apex:datatable value="{!InactiveLeads}" var="item" border="1">
<apex:column headervalue=" Name ">
<apex:outputText value="{!item.name}"/>
</apex:column>
<apex:column headervalue=" Created Date ">
<apex:outputText value="{!item.CreatedDate}"/>
</apex:column>
</apex:datatable>
</apex:component>
CONTROLLER
public class LeadsInfoController {
//capture the user id
public ID salesRepID {get; set;}
public List<community_lead__c> ClsInfo = new List<community_lead__c>();
public List<community_lead__c> getInactiveLeads() {
ClsInfo = [select Name, CreatedDate from community_lead__c where ownerId =: salesRepID];
return ClsInfo;
}
}
1) It must ONLY send to users that own at least 1 Lead record
2) It must only send ONE email to each of those users
3) it must send once a month (as mentioned)
If it is helpful, here are the details of my VF email. (I am using a component and controller)
VF TEMPLATE
<messaging:emailTemplate subject="Your Team's Leads- Owner Assignments" recipientType="User" relatedToType="User">
<messaging:htmlEmailBody >
Hi {!RelatedTo.firstName},
<p>The following leads have not yet been updated:</p>
<c:leadsinfo ToID="{!RelatedTo.Id}" />
<p>To update these leads, click on the "Lead Status" field located in the upper right on the lead page layout.</p>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
COMPONENT
<apex:component controller="LeadsInfoController" access="global">
<apex:attribute name="ToID" type="ID" description="the lead owner ID" assignTo="{!salesRepID}"/>
<apex:datatable value="{!InactiveLeads}" var="item" border="1">
<apex:column headervalue=" Name ">
<apex:outputText value="{!item.name}"/>
</apex:column>
<apex:column headervalue=" Created Date ">
<apex:outputText value="{!item.CreatedDate}"/>
</apex:column>
</apex:datatable>
</apex:component>
CONTROLLER
public class LeadsInfoController {
//capture the user id
public ID salesRepID {get; set;}
public List<community_lead__c> ClsInfo = new List<community_lead__c>();
public List<community_lead__c> getInactiveLeads() {
ClsInfo = [select Name, CreatedDate from community_lead__c where ownerId =: salesRepID];
return ClsInfo;
}
}
Have you tried checking with flow and process builder as this scenario seems to be one that can be done with them.
Looking forward to hearing back from you.
Regards,
Anutej.
All Answers
Have you tried checking with flow and process builder as this scenario seems to be one that can be done with them.
Looking forward to hearing back from you.
Regards,
Anutej.