This Knowledge Base Article shows you how to sort a mail merge for quotes by something other than the product ID. This one deals specifically with the product family or the product name, but can be used for the other columns in NewProduct.
Please read the Disclaimer before making any changes to the code in your system.


1. Go into Administration -> Customisation -> Quotes and click on the tab at the top for Views
2. Click on the view ‘vMailMergeChildrenQuotes’
3. Click on Change on the right hand side
4. Delete the script in ‘View Script’ and replace it with the following:

create view vtestcomp2 as select top(99.999) percent CASE WHEN NewProduct.prod_name IS NULL then quit_description else NewProduct.prod_name END AS
quit_ItemName, QuoteItems.*, NewProduct.* FROM QuoteItems Left Outer Join NewProduct
ON QuIt_ProductId = Prod_ProductId WHERE Quit_Deleted IS NULL
ORDER BY prod_productfamilyid

5. If you wants to sort it by product name, simply swap the last line “ORDER BY prod_productfamilyid” with “ORDER BY quit_ItemName”
6. Click save
7. Go to Administration -> System -> Metadata and refresh the metadata.
8. Now try a mail merge on a sample quote.


WARNING: The techniques or examples contained in this email are for illustrative purposes only, and have not been tested in a production environment. The techniques or examples used are not necessarily supported features of SAGE CRM, and may not have been previously tested or implemented on a production environment. Before attempting to implement any of these techniques or examples on a production environment, they should be tested thoroughly, as use of these techniques may cause unexpected behaviour. SAGE can accept no responsibility for any issues arising from the use of these techniques. Please ensure that you back up your database and application fully before implementing any changes of this nature.