====== ====== A common desire is to easily send invoices to customers when their orders reach the Sales status. This can be invoked manually or automatically when the status is changed. This How-To covers how to set up Control to manually send invoices to all new orders in Sale since the last email was sent. For information on automatically sending invoices when the order is made a sale, see [[how-to_email_invoices_on_orders_in_sale_automatically]]. ===== Concept ===== The basic approach used is: * Create an Order UDF to track which orders we've already sent invoices to. * Create a Saved Query to pull up all of the Sale Orders that haven't been sent invoices. * [Optional] Exclude all existing Sale orders by setting in the UDF value. * Create a Macro to send this group and invoice and set the UDF. ===== Notes ===== * This macro uses the Order contact's email. * This macro does not send the invoice for orders that are already closed (fully paid), though it could be easily modified to pull Closed orders also. * Make sure before you run this for the first time update the UDF on all the older Sale orders that you don't want to receive an invoice. ===== Steps ===== ==== Create UDF ==== Create an Order UDF called "Invoice Emailed" of type Date. This will be used to track who has received the email already. - Click on **Sales & Marketing | User Defined Field Setup**. - In the left panel, choose Transaction Under "User Defined Fields" - Click on the "Add" button in the middle panel - Enter "Invoice Emailed" as the Field Name. - Select "Date" as the Data Type. - Enter a Description and any category names if desired. - Make sure that "Show For Orders" is checked. - Make sure that "Show For Service Tickets" is checked (if you use service tickets). - Make sure that "Clear When Cloned" is checked. - Save the UDF. {{::http:www.ecyrious.comcontrolimagesinvoice_email_udf_setup.jpg?nolink&|}} - Restart Control so the UDF will be created. ==== Create Advanced Query ==== Create an advanced query to pull all orders in Sale where the UDF is not set. - Open Order Explorer - Clear all of the criteria except "Sale" so that only orders in Sale are showing. - Click on the "Advanced" button to switch to the Advanced Query setup. - Click on the "Modify Criteria..." button. - In the left panel, expand **Order Criteria | User Defined Fields | All Fields** and click on the "Invoice Emailed" UDF. The center panel will fill with date criteria for this UDF. - In the center panel, double click Double the criteria "Not Set". - In the bottom right panel, change the "Show:" range to All. {{::http:www.ecyrious.comcontrolimagesinvoice_email_advanced_query.jpg?nolink&|}} - Click OK. - Check that the query results look correct. - In the left panel, click on the "Save..." button. Enter "Invoices Not Emailed" as the query name. {{::http:www.ecyrious.comcontrolimagesinvoice_email_save_query.jpg?nolink&|}} ==== Set UDF on Existing Orders ==== **[Optional]** Set the "Invoice Emailed" UDF for all the existing Sale orders so that these are excluded from the initial emails. - With Advanced Explorer showing all the results, click on the down-arrow by "Run Macro Action" on the action menu. - Select "Run User Field Macro". A dialog window will appear. - Select "Transcation Fields" as the Category. - Select "Invoice Emailed" as the User Field Name. - Select "Set the field to the value below" - Select "Current Date When Executed" to set the UDF to todays date. - Click Execute to set the UDFs for all the orders selected in Explorer. {{::http:www.ecyrious.comcontrolimagesinvoice_email_macro_action.jpg?nolink&|}} ==== Create Macro ==== Create a Macro Using this query that Emails an Invoice - Click on "Marketing Home" on the main Toolbar. - Click on "Macro Setup". This will open the Macro Setup Window. - Click on "Order Macros" in the left panel. - Click on "New Macro" at the top of the left panel. - Enter "Email New Sale Invoices" as the Macro Name on the **Description Tab**. - Click on the **Trigger Tab**. - We want to run this manually, so click on "Run this macro manually or on a schedule". - Choose to "Use a saved query" under this otpion. - Select the query we saved above, "Invoices Not Emailed" from the list. - Click on the **Actions Tab** - The macro tab automatically starts with two pop-up message prompts. We will use before we run and one after. - Click in the "Message Text" box under the "Prompt to Begin" action tab. Type a message such as: