You need to sign in to do that
Don't have an account?

Custom send email notification checkbox on Visualforce Page
Hi All,
I have created a custom button on case feed that helps to change owner either to user or queue. Now, I need to include a send email notification checkbox in that visualforce page that will send email when case owner is changed same as standard SFDC Change Owner page.
Please can anyone help? Here is my visualforce and apex code.
Apex Code
I have created a custom button on case feed that helps to change owner either to user or queue. Now, I need to include a send email notification checkbox in that visualforce page that will send email when case owner is changed same as standard SFDC Change Owner page.
Please can anyone help? Here is my visualforce and apex code.
apex:page tabStyle="Case" standardController="Case" extensions="ChangeCaseOwner" sidebar="false"> <apex:form id="formId"> <apex:includeScript value="/soap/ajax/26.0/connection.js"/> <apex:includeScript value="/support/console/26.0/integration.js"/> <apex:inputHidden id="isInConsole" value="{!isInConsole}" /> <apex:sectionHeader title="Change Case Owner"/> <!-- <p>This screen allows you to transfer cases from one user or queue to another. When you transfer ownership, the new owner will own:</p> <ul><li>all open activities (tasks and events) for this case that are assigned to the current owner</li></ul> <p>Note that completed activities will not be transferred. Open activities will not be transferred when assigning this case to a queue.</p> --> <apex:pageBlock mode="Edit"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons location="bottom"> <apex:outputText rendered="{!shouldRedirect}"> <script type="text/javascript"> window.top.location.href = '{!redirectUrl}'; </script> </apex:outputText> <apex:commandButton value="Save" action="{!save}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <br/><apex:pageBlockSection title="Select New Owner" collapsible="false" columns="3"> <apex:pageBlockSectionItem > <apex:outputLabel value="Owner"></apex:outputLabel> <apex:inputField value="{!Case.ownerId}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <script type="text/javascript"> document.getElementById("j_id0:formId:isInConsole").value = sforce.console.isInConsole(); </script> </apex:page>
Apex Code
public class ChangeCaseOwner { ApexPages.StandardController controllerInstance; public String redirectUrl {public get; private set;} public Boolean shouldRedirect {public get; private set;} public String isInConsole{get; set;} public String browserUrlforRedirection{get;set;} public ChangeCaseOwner (ApexPages.StandardController controller) { controllerInstance = controller; } public pageReference save () { controllerInstance.save(); case caseRecord = (Case)controllerInstance.getRecord(); shouldRedirect = true; system.debug('correctVal' + isInConsole); String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm(); String url; if(isInConsole == 'false') { url = baseUrl + '/' + caseRecord.Id ; system.debug('inside false'); } else{ url = baseUrl + '/console' ; } system.debug('final url' + url); redirectUrl = url; system.debug(redirectUrl); //redirectUrl = 'https://cs30.salesforce.com/console'; return null; } public pageReference cancel () { case caseRecord = (Case)controllerInstance.getRecord(); shouldRedirect = true; system.debug('correctVal' + isInConsole); String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm(); String url; if(isInConsole == 'false') { url = baseUrl + '/' + caseRecord.Id ; } else{ url = baseUrl + '/console' ; } redirectUrl = url; return null; } }
Below link will show you how to send email using apex, just in case you were not aware of it
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm
For the check box add a Boolean public variable in the controller, and use the inputCheckbox with the value to the boolean variable, then use this variable to send out email.
Below is an example with the checkbox Below is the controller
Thanks
Adda
Below is the visualforce page, added the checkbox. Please position the item as required.