Apex Commandbutton Class

Custom controller is an apex class which is used to implement logic of visualforce page without leveraging the standard functionality. This API returns an Application Express region object, which is used to access region related functions and properties. Wes Nolte posted a great tip on his blog Silver Lining on passing javascript values to an Apex controller. Visualforce can be leveraged to implement user interfaces as per our requirements, many times we need solutions that are dynamic enough that would cater to our future needs. A wrapper or container class is a class, data structure, or an abstract data type whose instances are a collections of multiple objects. This method as we can see takes an argument of message class object. Salesforce has increased the limit for the total number of Apex classes that you can schedule concurrently to 25 (the previous limit was 10). Our goal is to share information about how we build on the platform so you can gain insight into what may or may not work for you. There is a really good example of invoking apex code through apex code here. Multi-row: Avoid using an inner class to view/edit records II. The constructor require two arguments, first is the severity of the message. Salesforce rest api integration between Salesforce and Salesforce,Salesforce api,Salesforce rest api,Salesforce rest api integration to fetch a record. Dear awesome readers, I have been in your shoes trying to pull my hair over wrappers! But sincerely, they ain't that tough. UI is blocked) The Javascript is executed in the Salesforce DOM, which is now on the "don't do" list when you want to pass the Salesforce Security Review There are few alternatives Lightning Quick Actions. com platform. What is the use of a wrapper class in Salesforce?. GitHub Gist: instantly share code, notes, and snippets. Create an Apex class called ParseTest. In this Salesforce tutorial, we will understand about Apex getter method and setter method in detail. Apex class Name: ViewSurveyController. We must add some more attributes with this tag styleClass which will have the css style name and rendered which will be True or False. In this class we can see that the return type is Component. What is the Wrapper class: A Wrapper class is a container class, a data structure, or an abstract data type whose instances are collections of other objects. valueof(i),city__c='City'+string. The usage is restricted with limited introspection and the dynamism available in APEX. Use of limit apex methods to avoid hitting governor limits 7. after Adding a field on Case Object now we need to do some changes in the Apex Class component and VF Page. A custom controller is the user defined an Apex class that implements all of the logic for a page without leveraging a standard controller. Do you have more than 1 controller extension in tag? they'd be checked for matching function names from right to left (so if you have few classes maybe it's calling the match from a class you're not. The following method checks that you're actually parsing XML. Lets take some sample code to understand each component. any suggestion. An Apex class will be generated during the importation of the WSDL to aid in making the connection and exercising the methods. commandButton value="Greeting" - [The button name] Checkout SalesForce Tutorial. Apex Metadata API Introduction The Salesforce Metadata API allows you to perform many org configuration and setup features programatically. below is the simple interface i gonna create for the demo. The code in this sample is a bit contrived of course, but if ValidateAndSaveRecord() does detect a warning condition, it sets a String property on the controller and returns a null PageReference to our Visualforce page. I wanted to […] » Sites & Visualforce: Some early lessons (The Enforcer. The strange thing is that if I put the button on the base visualforce. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. The usage is restricted with limited introspection and the dynamism available in APEX. You can use under to open the visualforce page in new tab. This post is a slight tweak of yesterday's post, Passing Parameters with a CommandLink. com platform. Understand How To Send Emails From Your Apex Class In Salesforce Before You Start Sending an email from Apex Class is so easy. This component must be a child of tag. Tips to pass Salesforce Platfrom Developer 1 Certification - A detailed map to study guide. A wrapper class is a custom object defined by programmer wherein he defines the wrapper class properties. Using collections, streamlining queries and efficient for loops 5. The extension is simply an Apex class. Print Preview. commandButtonのaction処理後にjavascript処理の実行はできないと思っていました。 onCompleteイベントで実行できたんですね。. public class ManageListController {public List wrappers {get; set;} public static Integer toDelIdent {get; set;} public static Integer addCount {get; set;}. I wanted to […] » Sites & Visualforce: Some early lessons (The Enforcer. Pagination is the best option you can opt for. This Apex class is the Part of Survey force App. if I press the fetch data button the page is gonna display the data from multiple objects which is not related with each other. Multi-row: Paging using StandardSetController. The strange thing is that if I put the button on the base visualforce. Another question has been sent to us and we thought it would be good to share these step by step directions with the Salesforce development world. Finally, as requested by Salesforce, you'll need a testclass for the two apex classes (I've made a single apex test class to test both : @istest private class opportunityProductEntryTests { static testMethod void theTests(){ TestUtilities tu = TestUtilities. Field sets can be displayed on Visualforce pages and added to managed packages. This Visualforce Page then can point to an Apex Class, which should contain our business logic, by using the controller attribute. A button that is rendered as an HTML input element with the type attribute set to submit, reset, or image, depending on the tag's specified values. Apex In order to fullfill the requirements specified in the Use Case, we will implement a couple of functions in the controller of the popup window. Here in the Save() function the data you have enter in the text box will be saved. The PageReference object functions less as a page reference mechanism, and more as a page redirection mechanism. This API returns an Application Express region object, which is used to access region related functions and properties. Detail Page Custom Button Template. With sharing and without sharing in Apex Class With sharing and without sharing in Apex Class determines whether the class should enforce all the Organization sharing settings. Create an Apex class called ParseTest. We have different components that supports displaying messages in a visual force page like ,, and. A custom controller is the user defined an Apex class that implements all of the logic for a page without leveraging a standard controller. There was a requirement where i needed to build a list which can be filtered based on the starting alphabet. Apex class :. Reviewing in a few weeks. The main way to start/execute Apex Batch processes is creating an OnClick JavaScript Button. Tips to pass Salesforce Platfrom Developer 1 Certification - A detailed map to study guide. This is an educational blog for people interested in development on the Salesforce platform. Salesforce rest api integration between Salesforce and Salesforce,Salesforce api,Salesforce rest api,Salesforce rest api integration to fetch a record. Within Apex & Visualforce this can be extremely helpful to achieve many business scenarios within the. To insert data to Custom object using Apex just understand the below code. A wrapper or container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. Calling a REST Web Service (JSON) with Apex. In this blog, we will take on the reRender beast, which really isn't a beast at all. Refers to a PageReference for a Visualforce page that has already been saved in your organization. The biggest draw for Big Objects is that they can provide consistent performance for objects with records upwards of a billion. There are two issues with this: The apex process (WebService) is executed synchronously (i. Wrapper Class:. There is really no excuse for having an ugly web application; even if it is a "business application". Do you have more than 1 controller extension in tag? they'd be checked for matching function names from right to left (so if you have few classes maybe it's calling the match from a class you're not. This allows you to attach external documents to any object record, in much the same way that you can add a PDF or photo as an attachment to an email. What is the wrapper class 1. Download this repo and use eclipse or jenkins to deploy the src folder's content. The Http Response and Request are defined in class The page and the class would look like this,. I am using here single object Job__c and 3 apex classes to meet this requirement. Wildcards: * - zero or more characters? - one character Operators: Boolean operators: AND, OR, and NOT "Double quotes" indicate exact phrase match (Parentheses) around search terms, groups them together. Sample Class: public class AccountCreation{ public Account objAcc; public String name; public AccountCreation() { } public Account newAccount() { objAcc = new Account(Name … Continue reading How to Cover Catch Block in Apex Test Class in Salesforce. Salesforce Developer Network: Salesforce1 Developer Resources. It looks like a common spreadsheet but has. You can wrap different objects types or any other types in a wrapper class. Check out how we solved them to see if it could help you. I have a method which sends an email with csv attachments. * You must also use the 'recordSetVar' attribute on apex:page if you wish to create List View button. This can be used according to our need, or completely omitted. In above example I used Account objects date field SLAExpirationDate__c to take input from user, you can take input using text field also, but in that case please format the date properly. In below example we will learn about how we can delete and Update selected records using wrapper Class. For example, if you want to have single container which holds various types of variables or Sobject or Collection. Note that the wrapper class provides a useful constructor, that creates the wrapped record and automatically populates the Name of the Account based on the unique identifier. Whenever the visualforce pages need to run entirely in system mode and it does not enforce the permissions and field-level security of the current user the custom controller works. In the following scenario we are displaying boolean and list datatypes. How do I call Apex code from a Custom Button? The steps are as follows to add either a Detail or a List View button (as illustrated below) to Standard or Custom Object. January I posted about how to invoke Apex from a Custom Button using a Visualforce Page. A wrapper or container class is a class, data structure, or an abstract data type whose instances are a collections of other objects. Now that you know more about how the Lightning Platform relates to the. It works fine when I run it from the "execute anonymous window". The standard apex:inputfield component for a date field generates a link next to the input field, taking a lot of space. It is an inner class or container in Salesforce. Show the different methods available to go to the first, previous, next and last pages. Incredible developer blog is incredibly created for salesforce developers who have creative approaches as a programmer. commandButtonのaction処理後にjavascript処理の実行はできないと思っていました。 onCompleteイベントで実行できたんですね。. Typically you save a record with a commandButton that invokes a method in the Controller specified by the action attribute. It's a bit tedious to write out, but mostly just copy pasta. Below is the sample code snippet, I have created one controller class and one visual force page associated with it. Very important to note, although there can only be a single controller on a page, many extensions can be attached to the page. Sample Wrapper Class using Apex in Salesforce apex:commandButton not working sometime Apex Code: global class batchAccountUpdate implements Database. This post is a slight tweak of yesterday's post, Passing Parameters with a CommandLink. The page would look like this:. Here is a sample code to make them really fancy! This is what the message looks like:. You want to create a page that captures input from users, and that input spans multiple sObjects. Wrapper class is used to display different types of datatypes in a single table. Code examples given by Salesforce are in Java as the API is a SOAP API. SingleEmailMessage class handles the email functionality available to Salesforce. Finally, as requested by Salesforce, you'll need a testclass for the two apex classes (I've made a single apex test class to test both : @istest private class opportunityProductEntryTests { static testMethod void theTests(){ TestUtilities tu = TestUtilities. The standard apex:inputfield component for a date field generates a link next to the input field, taking a lot of space. Hello folks, We have interesting here Today I am going to attach the file to any object related list in attachment object. If we want to import data in to multiple objects using single CSV file, in that case we can not use any data loaders to load data. Within that attribute include a width property and set it something around 100 pixels or so. Pagination with Wrapper Class ( with maintaing the state of selected records) Problem :- 1) One thing I noticed is the Checkboxes don't maintain state in pagination with StandardSetController if you check one, go to the next page, then go back. Refers to a PageReference for a Visualforce page that has already been saved in your organization. It includes a private helper method called inspectResults for inspecting the results of the email send call. If you like fancy words, you might call Apex a strongly typed, object-oriented language that allows developers to execute flow and transaction-control statements on the Lightning Platform server, in conjunction with calls to the Lightning Platform APIs. apex means that the namespace of generated component will be apex. Passing Javascript values to Apex Controller. Using @future appropriately. I have come across this situation more than often, and using the standard required=true on inputfield or inputText sometimes prevent any submission of the page, which is good for some reason, but will prevent also any refresh. There are two reasons for this. On every component we have Dynamic Visualforce Notation in component reference for example. The search result could get pretty big at times and I always needed to over come the limitations and show large number of rows in the screen. Command buttons must be in an apex:outputPanel, so both buttons appear on the page when each apex:facet is active. Apex In order to fullfill the requirements specified in the Use Case, we will implement a couple of functions in the controller of the popup window. In this class we have used the method addMessage to add an object of type pagemessage to the visualforce page. ActionFunction results in a javascript function being rendered on the page. Crypto class: Crypto class provides the following functions to encrypt and decrypt data: encrypt() decrypt() encryptWithManagedIV() decryptWithManagedIV(). Apex is a Salesforce programming language that you can use to customize business processes in your org. Within Apex & Visualforce this can be extremely helpful to achieve many business scenarios within the. This will automatically create a new content record and put it in your personal workspace. でaction処理を実行するときに、 で引数を渡す方法についてです。 を使う場合はPage側で次のように書きます。. Salesforce rest api integration between Salesforce and Salesforce,Salesforce api,Salesforce rest api,Salesforce rest api integration to fetch a record. commandButton value="Greeting" - [The button name] Checkout SalesForce Tutorial. This Apex class is the Part of Survey force App. In this blog, we will take on the reRender beast, which really isn't a beast at all. A wrapper or container class is a class, data structure, or an abstract data type whose instances are a collections of other objects. What is a BigObject? Big Objects allow for storage of massive amounts of data on the Salesforce platform. Incredible developer blog is incredibly created for salesforce developers who have creative approaches as a programmer. Forget pagination I'm gonna demonstrate a simple example of displaying data from unrelated multiple objects so the article works like a primer for the concept of wrapper classes. Visualforce File Upload - for Any SObject How to Upload Attachment to any SObject using Visualforce This article explains how you can upload file attachments to any SOobject using Visualforce. Section - Page Block 2 - Standard Controller Example. Its a custom type defined by the Salesforce Dev where he defines the properties of the wrapper class. I wanted to […] » Sites & Visualforce: Some early lessons (The Enforcer. Action methods In Visualforce, you can define action methods using the and other tags. Apex best practices 1. You can conditionally render the apex:commandButton based on whatever you want. GitHub Gist: instantly share code, notes, and snippets. com users that allows you to integrate prospect assignments with your current salesforce. When the popup is opened, the constructed first extracts the from searchString, accountId and opportunityId from the page parameters. SingleEmailMessage class handles the email functionality available to Salesforce. Advanced Visualforce Examples. You have to create custom class and then add it as extension to standard controller. Use ListView in Visualforce with Paging and Navigation. The PageReference object functions less as a page reference mechanism, and more as a page redirection mechanism. If you like fancy words, you might call Apex a strongly typed, object-oriented language that allows developers to execute flow and transaction-control statements on the Lightning Platform server, in conjunction with calls to the Lightning Platform APIs. You want to create a page that captures input from users, and that input spans multiple sObjects. Attachment field allows users to be able to attach notes and attachments to custom object records. But this alone cant help you. We have not included any message components in the VF. rerendering commandbutton both top and bottom one Visualforce Page Apex disable apex class ( 1 ) disable apex. Section - Page Block 2 - Standard Controller Example. Syntax of inner class :. I want to use standard save only (not custom). Multi-row: Avoid using an inner class to view/edit records II. Sometime also, using apex:inputText with required=true, doesn't work. To keep article simple, I am posting complete Visualforce and Apex code with Comments inside. Fore main webservice call from an external system call the Java Function defined in page which is calling RemoteAction defined in class. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. Apex provides the Crypto class to protect our data from eavesdroppers. This is achieved by using a Salesforce Apex feature called "Generate from WSDL. In this Salesforce tutorial, we will understand about Apex getter method and setter method in detail. Here is the solution. The extension is simply an Apex class. Check out how we solved them to see if it could help you. Disclaimer: General recommendation from salesforce - For existing pages - you don't try to adapt them to match the visual design of Lightning Experience. Visualforce Page for Upload File as an Attachment OR in Chatter. The strange thing is that if I put the button on the base visualforce. You have to create custom class and then add it as extension to standard controller. Crypto class: Crypto class provides the following functions to encrypt and decrypt data: encrypt() decrypt() encryptWithManagedIV() decryptWithManagedIV(). Wrapper class in Apex Salesforce A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members. NET platform, let's jump right in and create an Apex class using Developer Console. This is the basic for all other complex apex programming. This is because the list that we use to display records on page, is getting refreshed everytime, and not retaining the values. What is tag? This tag defines JavaScript functions to be called from JavaScript code. Organizations with field sets deployed can add, remove, or rearrange fields from the field set, without altering the Visualforce page. With sharing and without sharing in Apex Class With sharing and without sharing in Apex Class determines whether the class should enforce all the Organization sharing settings. The question was how to do Pagination within Salesforce if I have 100,000 records. The Http Response and Request are defined in class The page and the class would look like this,. i want to create pivot table for insert time sheet. below is the simple interface i gonna create for the demo. Section - Page Block 2 - Standard Controller Example. Our goal is to share information about how we build on the platform so you can gain insight into what may or may not work for you. could you please help me with code. Finally, as requested by Salesforce, you'll need a testclass for the two apex classes (I've made a single apex test class to test both : @istest private class opportunityProductEntryTests { static testMethod void theTests(){ TestUtilities tu = TestUtilities. Action, and then when your commandButton uses this reference, it will call the method defined in the page controller. Pagination is the best option you can opt for. could you please help me with code. The trouble with Picklists, Visualforce, and Record Types I recently came across a problem where I had to render the values in a picklist on a custom visualforce page. Save the Attachment using Apex Class and Visualforce Page in Salesforce. This is because the list that we use to display records on page, is getting refreshed everytime, and not retaining the values. Using JSON RESTful Web Services with Salesforce. Test class for Visualforce controller: @isTest public with sharing class TestMerchantCustom_ctrl {public static TestMethod void TestMerchantCustom_ctrlMethod(). In this case, I want to demonstrate few techniques: Building a paging sytem using the ApexPages. You have to create custom class and then add it as extension to standard controller. And also the List needs to remember the selections made as we move through other pages. Use the code ParseText ZIP file referenced below. What is the wrapper class 1. The problem is that the users of this page were sometimes double-clicking on the button instead of just clicking on it. But I have found another way to invoke the apex method without using visualforce pages. In this blog, we will take on the reRender beast, which really isn't a beast at all. The page is refreshed, but the method registered in the commandButton {!performUnlinkContact} is not called. Another question has been sent to us and we thought it would be good to share these step by step directions with the Salesforce development world. I am using here single object Job__c and 3 apex classes to meet this requirement. The main way to start/execute Apex Batch processes is creating an OnClick JavaScript Button. Adding Action Methods to an Apex Controller In this lesson, you'll add action method to your controller to allow it to handle clicking a new Add to Cart button, as well as a new method that outputs the contents of a shopping cart. It works fine when I run it from the "execute anonymous window". Get visualforce element in javascript If you use Javascript in Visualforce page, you may find out that it is more time consuming to get elements from page. Getting Started. This may be another Visualforce page, another standard page, or, it could be a web page outside your Salesforce org. Finally, as requested by Salesforce, you'll need a testclass for the two apex classes (I've made a single apex test class to test both : @istest private class opportunityProductEntryTests { static testMethod void theTests(){ TestUtilities tu = TestUtilities. com blog) Said, July 28, 2009 @ 5:10 am. Advanced Visualforce Examples. pageBlockSectionItem >New Company: value="{!Account. Incredible developer blog is incredibly created for salesforce developers who have creative approaches as a programmer. he had done it using web service API in. You need to define myParam with a get/set at the top class level. after Adding a field on Case Object now we need to do some changes in the Apex Class component and VF Page. Learn with flashcards, games, and more — for free. Here is a sample code to make them really fancy! This is what the message looks like:. Apex gives the flexibility to write our own cryptographic functions for ensuring the integrity of our data. Hi, I have created styleclass for command button. In this class we can see that the return type is Component. Lets take some sample code to understand each component. In Apex and Visualforce this type of class can be extremely useful but to a new developer the talk of wrapper classes may fly right over your head, it definitely did for me. This doSave() function on my Apex controller class is inserting a record into the database. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. Understand How To Send Emails From Your Apex Class In Salesforce Before You Start Sending an email from Apex Class is so easy. Forget pagination I'm gonna demonstrate a simple example of displaying data from unrelated multiple objects so the article works like a primer for the concept of wrapper classes. I have an apex datatable returning some User fields from a list in my apex class. Although most of the time, when you want to have multiple rows in the page a wrapper class is used, this technique is not required. That should get the layout to look as close as possible to our goal. This may be another Visualforce page, another standard page, or, it could be a web page outside your Salesforce org. This is achieved by using a Salesforce Apex feature called "Generate from WSDL. Preparing for a Salesforce Certification exam always raises the question "What do I need to study and where can I find any goo. A custom controller is the user defined an Apex class that implements all of the logic for a page without leveraging a standard controller. Adding Action Methods to an Apex Controller In this lesson, you'll add action method to your controller to allow it to handle clicking a new Add to Cart button, as well as a new method that outputs the contents of a shopping cart. The rerender attribute on the commandButton changes the behavior from full to partial page, and specifies what areas of the page will be updated on the response — in this case, the apex:pageBlock component tags with the named identifiers. If you like fancy words, you might call Apex a strongly typed, object-oriented language that allows developers to execute flow and transaction-control statements on the Lightning Platform server, in conjunction with calls to the Lightning Platform APIs. It works fine when I run it from the "execute anonymous window". apex:actionRegion: apex:listViews: apex:actionSupport: apex:message: apex:commandButton: apex:pageBlockButtons: apex:commandLink: apex:pageBlockSection: apex:component. Use the code ParseText ZIP file referenced below. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. In this class we can see that the return type is Component. LayoutDescriberHelper. Field sets can be displayed on Visualforce pages and added to managed packages. This component must be a child of tag. commandButtonのaction処理後にjavascript処理の実行はできないと思っていました。 onCompleteイベントで実行できたんですね。. OutputPanel, which means that the returned tag will be. There was a requirement where i needed to build a list which can be filtered based on the starting alphabet. StandardSetController. This is indeed great! But I think perhaps you are generally referring Apex Interview Questions Answers And Tutorial which is getting unsustainable. Multi-row: Paging using StandardSetController. Get visualforce element in javascript If you use Javascript in Visualforce page, you may find out that it is more time consuming to get elements from page. Preparing for a Salesforce Certification exam always raises the question "What do I need to study and where can I find any goo. The style class of these commandButton is 'btn button1', not 'button1' I define. Open Visualforce in new Tab for PageReference Hi All, Visualforce force page can open in new tab use to command button. com workflow. This apex class does not have much use and the only important piece of code in it is the first line of the function of testinput(). This can be used according to our need, or completely omitted. Visualforce CSV Download. To upload a csv file, we need a Visualforce page and an Apex class. It has been a popular post and is a topic which is of interest to many developers. Create an Apex class called ParseTest. also i try to cover following scenario a batch Apex job that contains 20,000 records and is executed without the optional scope parameter is considered five transactions of 200 records each */. Nice "Please Wait" message (uses tag) The Visualforce tag ActionStatus helps you write "Please Wait" messages as simple texts, but you can make them very fancy. Apex provides the Crypto class to protect our data from eavesdroppers. com platform. Using collections, streamlining queries and efficient for loops 5. I would like to include a column "This Month's Sales" which would return the total $ of opps closed won this month. any suggestion. It's a bit tedious to write out, but mostly just copy pasta. Lets take some sample code to understand each component. Visualforce Page for Upload File as an Attachment OR in Chatter. In above example I used Account objects date field SLAExpirationDate__c to take input from user, you can take input using text field also, but in that case please format the date properly. What is the use of a wrapper class in Salesforce?. * You must also use the 'recordSetVar' attribute on apex:page if you wish to create List View button. The strange thing is that if I put the button on the base visualforce. OK, I Understand. This scenario mainly describes the usage of Wrapper class. So here I would like to show a problem which can also be solved by inner class. When trying to be dynamic and using a repeat to populate the Lists it fails as well for both and. This is what I am going to demonstrate you, how to send email from APEX. This apex class does not have much use and the only important piece of code in it is the first line of the function of testinput(). Any salesforce developer can share here their problems and communicate with all other developers. You have to create custom class and then add it as extension to standard controller. Wrapper Class:. The style class 'button1' defined in style page can't be applied to the commandButton in the regular page. The visual portion of the page which includes the CSS, HTML and Apex Visualforce tags, which help to create more HTML, are kept in a Visuaforce Page. generateTest();. You use to execute action behalf of. Here is the solution. Pagination is the best option you can opt for. We have different components that supports displaying messages in a visual force page like ,, and. To make any wrapper class more powerful, try using highly calculated properties within your wrapper class instead of opting highly complicated rendering. Tips to pass Salesforce Platfrom Developer 1 Certification - A detailed map to study guide. We have not included any message components in the VF. Public Groups are used primary for security. Visualforce pages that contain a form component also contain an encrypted, hidden form field that encapsulates the view state of the page. You need to define myParam with a get/set at the top class level. Passing parameters from Visualforce page to Apex controller via To pass parameters from the Visualforce page to the controller, you can use the as demonstrated on this sample. Section - Page Block 2 - Standard Controller Example. The standard apex:inputfield component for a date field generates a link next to the input field, taking a lot of space. Organizations with field sets deployed can add, remove, or rearrange fields from the field set, without altering the Visualforce page. Understand How To Send Emails From Your Apex Class In Salesforce Before You Start Sending an email from Apex Class is so easy. Note that the wrapper class provides a useful constructor, that creates the wrapped record and automatically populates the Name of the Account based on the unique identifier. There may be situations in which you would not want a workflow email alert, because either your criteria to send an email may be too complex or the person whom you want to send an email has to be determined dynamically In such situations you can choose to send an email from a Apex Class Sending an email from a Apex Class is so easy. The code in this sample is a bit contrived of course, but if ValidateAndSaveRecord() does detect a warning condition, it sets a String property on the controller and returns a null PageReference to our Visualforce page.