Contents
- Title and Copyright Information
- Preface
- 1 Introduction
- 2 Groovy Basics
- Commenting Your Scripts
- Defining Variables
- Referencing the Value of a Field in the Current Object
- Working with Numbers, Dates, and Strings
- Using Substitution Expressions in Strings
- Using Conditional Expressions
- Using the Switch Statement
- Returning a Boolean Result
- Assigning a Value to a Field in the Current Object
- Writing Null-Aware Expressions
- Understanding Null Versus the Empty String
- Understanding Secondary Fields Related to a Reference
- Using Groovy's Safe Navigation Operator
- Assigning a Value to a Field in a Related Object
- Printing and Viewing Diagnostic Messages
- Working with Lists
- Working with Maps
- Working with Ranges
- 3 Examples of Each Context Where You Can Use Groovy
- Providing an Expression to Calculate a Custom Formula Field's Value
- Providing an Expression to Calculate a Custom Field's Default Value
- Defining a Field-Level Validation Rule
- Defining an Object-Level Validation Rule
- Defining Reusable Behavior with an Object Function
- Enabling External Visibility of an Object Function
- Defining an Object-Level Trigger to Complement Default Processing
- Defining a Field-Level Trigger to React to Value Changes
- Converting a Trigger to Custom Code
- 4 Groovy Tips and Techniques
- Using the Related Object Accessor Field to Work with a Parent Object
- Using the Related Object Accessor Field to Work with a Referenced Object
- Using the Related Collection Accessor Field to Work with Child Rows
- Accessing Current Date and Time from the Application Server
- Accessing Current Date and Time from the Database
- Understanding Additional Built-in Groovy Functions
- Testing Whether a Field's Value Is Changed
- Avoiding Validation Threshold Errors By Conditionally Assigning Values
- Understanding "Before Commit" Performance Impact
- Detecting Row State in After Changes Posted to Database Trigger
- Avoiding Posting Threshold Errors By Conditionally Assigning Values
- Functional Restrictions in Trigger Scripts
- Passing the Current Object to a Helper Function
- Referencing Original Values of Changed Fields
- Raising a Warning From a Validation Rule Instead of an Error
- Throwing a Custom Validation Exception
- Returning Locale-Sensitive Custom Strings
- Raising a Trigger's Optional Declaratively-Configured Error Message
- Accessing the View Object for Programmatic Access to Business Objects
- Defining the Sort Order for Query Results
- Finding an Object by Id
- Finding Objects Using a View Criteria
- Using a Simple View Criteria
- Syntax of View Criteria Filter Expressions
- Tips for Formatting Longer Criteria Across Multiple Lines
- Using String Substitution for Literal Values into a View Criteria Expression Used Only Once
- Using Custom Bind Variables for View Criteria Used Multiple Times
- Using View Criteria to Query Case-Insensitively
- Limitations of View Criteria Filter Expressions
- Finding Rows in a Child Rowset Using findRowsMatchingCriteria
- Accomplishing More with Less Code
- Embracing Null-Handling in Conditions
- Embracing Null-Handling in Loops
- Understanding Groovy's Null-Safe Comparison Operators
- Using Functions as Objects with Closures
- Working More Cleverly with Collections
- Using Optional Method Arguments
- Creating a New Object
- Updating an Existing Object
- Permanently Removing an Existing Object
- Reverting Changes in a Single Row
- Understanding Why Using Commit or Rollback In Scripts Is Strongly Discouraged
- Using the User Data Map
- Referencing Information About the Current User
- Using Aggregate Functions
- Understanding the Difference Between Default Expression and Create Trigger
- Deriving Values of a Field When Other Fields Change Value
- Setting Invalid Fields for the UI in an Object-Level Validation Rule
- Determining the State of a Row
- Understanding How Local Variables Hide Object Fields
- Invoking REST Services from Your Scripts
- Creating a Service Connection
- Acquiring a New Service Object
- Setting Path Parameters If Needed
- Setting Query Parameters If Needed
- Setting HTTP Headers If Needed
- Using Groovy Maps and Lists with REST Services
- Checking Success Status and Handling Exceptions
- Calling Service Endpoint Methods
- Browsing Available Service Endpoint Methods
- Formatting Numbers and Dates Using a Formatter
- Working with Field Values Using a Parameterized Name
- 5 Best Practices for Groovy Performance
- 6 Understanding Common JBO Exceptions in Groovy Scripts
- 7 Supported Classes and Methods for Use in Groovy