The Definitive Guide to Sugarcrm Better Business Applications
Total Page:16
File Type:pdf, Size:1020Kb
The Definitive Guide to SugarCRM Better Business Applications ■ ■ ■ John Mertic i The Definitive Guide to SugarCRM: Better Business Applications Copyright © 2009 by John Mertic ISBN-13 (pbk): 978-1-4302-2439-6 ISBN-13 (electronic): 978-1-4302-2440-2 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Steve Anglin Technical Reviewer: Matt Heitzenroder, Roger Smith, Collin Lee Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Copy Editor: Jim Markham Coordinating Editor: Katie Stence Compositor: MacPS, LLC Artist: April Milne Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders- [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5939, e-mail [email protected], or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. ii Contents at a Glance ■Contents at a Glance ............................................................................................. iv ■Contents ................................................................................................................. v ■About the Author .................................................................................................. xi ■About the Technical Reviewers ........................................................................... xii ■Acknowledgments .............................................................................................. xiii ■Introduction ........................................................................................................ xiv Part 1: The SugarCRM Platform ................................................................................1 ■Chapter 1: What Is SugarCRM?..............................................................................3 ■Chapter 2: MVC Architecture ...............................................................................11 ■Chapter 3: Metadata Layer ..................................................................................35 ■Chapter 4: Web Services ......................................................................................55 ■Chapter 5: More Platform Features .....................................................................77 Part 2: Customizing SugarCRM Out of the Box ....................................................107 ■Chapter 6: Easy Customizations Using Studio ...................................................109 ■Chapter 7: Workflows and Logic Hooks .............................................................125 ■Chapter 8: Overriding Existing Code ..................................................................151 Part 3: Building New Functionality on Top of SugarCRM .....................................169 ■Chapter 9: Using Module Builder to Build Custom Modules ..............................171 ■Chapter 10: Building a Custom Module Manually .............................................195 ■Chapter 11: Designing a Complete Application .................................................219 ■Index ..................................................................................................................219 iv Contents ■Contents at a Glance ............................................................................................iv ■Contents ................................................................................................................v ■About the Author ..................................................................................................xi ■About the Technical Reviewers...........................................................................xii ■Acknowledgments..............................................................................................xiii ■Introduction........................................................................................................ xiv Part 1: The SugarCRM Platform................................................................................1 ■Chapter 1: What Is SugarCRM? .............................................................................3 The Company .................................................................................................................. 3 Rapid Growth—Harnessing Open Source and SaaS..............................................................................4 The Product.....................................................................................................................4 The Community............................................................................................................... 7 Sugar Forums and Wiki..........................................................................................................................7 SugarExchange and SugarForge............................................................................................................7 Sugar Developer Zone............................................................................................................................8 Getting SugarCRM..................................................................................................................................8 Summary.........................................................................................................................9 ■Chapter 2: MVC Architecture...............................................................................11 What Is MVC?................................................................................................................ 11 MVC the Sugar Way ...................................................................................................... 12 SugarApplication..................................................................................................................................13 SugarController....................................................................................................................................15 SugarView............................................................................................................................................18 v ■ CONTENTS Entrypoints.................................................................................................................... 21 What About the Model?................................................................................................. 22 Bean Classes and SugarObjects ..........................................................................................................22 Vardefs.................................................................................................................................................24 Fields....................................................................................................................................................24 Indexes.................................................................................................................................................28 Relationships .......................................................................................................................................29 Database Layer ....................................................................................................................................31 Sugar Before MVC......................................................................................................... 33 Summary....................................................................................................................... 33 ■Chapter 3: Metadata Layer..................................................................................35 DetailView and EditView .............................................................................................. 35 How the DetailView and EditView Classes Work.......................................................... 38 SugarFields ..........................................................................................................................................40 ListViews..............................................................................................................................................41 Defining Search Fields .........................................................................................................................44