Salesforce Apex Language Reference

1419
Version 29.0: Winter 14 Force.com Apex Code Developer's Guide Last updated: January 3, 2014 © Copyright 20002013 salesforce.com, inc. All rights reserved. Salesforce.com is a registered trademark of salesforce.com, inc., as are other names and marks. Other marks appearing herein may be trademarks of their respective owners.

description

---

Transcript of Salesforce Apex Language Reference

  • Version 29.0: Winter 14

    Force.com Apex Code Developer's Guide

    Last updated: January 3, 2014

    Copyright 20002013 salesforce.com, inc. All rights reserved. Salesforce.com is a registered trademark of salesforce.com, inc., as are othernames and marks. Other marks appearing herein may be trademarks of their respective owners.

  • Table of Contents

    Getting Started....................................................................................................................................1

    Chapter 1: Introduction...............................................................................................................1Introducing Apex...........................................................................................................................................................2What is Apex?...............................................................................................................................................................2When Should I Use Apex?............................................................................................................................................4How Does Apex Work?................................................................................................................................................5Developing Code in the Cloud......................................................................................................................................5What's New?.................................................................................................................................................................6Understanding Apex Core Concepts.............................................................................................................................7

    Chapter 2: Apex Development Process.......................................................................................12What is the Apex Development Process?....................................................................................................................13Using a Developer or Sandbox Organization..............................................................................................................13Learning Apex.............................................................................................................................................................15Writing Apex Using Development Environments......................................................................................................16Writing Tests..............................................................................................................................................................17Deploying Apex to a Sandbox Organization...............................................................................................................18Deploying Apex to a Salesforce Production Organization..........................................................................................18Adding Apex Code to a Force.com AppExchange App..............................................................................................18

    Chapter 3: Apex Quick Start......................................................................................................20Writing Your First Apex Class and Trigger................................................................................................................20

    Creating a Custom Object...............................................................................................................................20Adding an Apex Class.....................................................................................................................................21Adding an Apex Trigger..................................................................................................................................22Adding a Test Class.........................................................................................................................................23Deploying Components to Production............................................................................................................25

    Writing Apex.....................................................................................................................................26

    Chapter 4: Data Types and Variables..........................................................................................26Data Types..................................................................................................................................................................27Primitive Data Types...................................................................................................................................................27Collections...................................................................................................................................................................30

    Lists.................................................................................................................................................................30Sets..................................................................................................................................................................32Maps................................................................................................................................................................33Parameterized Typing......................................................................................................................................34

    Enums.........................................................................................................................................................................34Variables......................................................................................................................................................................36Constants.....................................................................................................................................................................37Expressions and Operators..........................................................................................................................................38

    Understanding Expressions..............................................................................................................................38

    i

    Table of Contents

  • Understanding Expression Operators..............................................................................................................39Understanding Operator Precedence...............................................................................................................45Using Comments.............................................................................................................................................45

    Assignment Statements...............................................................................................................................................45Understanding Rules of Conversion............................................................................................................................47

    Chapter 5: Control Flow Statements..........................................................................................49Conditional (If-Else) Statements................................................................................................................................50Loops...........................................................................................................................................................................50

    Do-While Loops.............................................................................................................................................51While Loops....................................................................................................................................................51For Loops........................................................................................................................................................51

    Chapter 6: Classes, Objects, and Interfaces.................................................................................54Understanding Classes.................................................................................................................................................55

    Apex Class Definition......................................................................................................................................55Class Variables.................................................................................................................................................56Class Methods.................................................................................................................................................56Using Constructors..........................................................................................................................................59Access Modifiers..............................................................................................................................................60Static and Instance...........................................................................................................................................61Apex Properties...............................................................................................................................................64Extending a Class............................................................................................................................................66Extended Class Example.................................................................................................................................68

    Understanding Interfaces.............................................................................................................................................71Custom Iterators..............................................................................................................................................72

    Keywords.....................................................................................................................................................................74Using the final Keyword..................................................................................................................................74Using the instanceof Keyword.........................................................................................................................74Using the super Keyword.................................................................................................................................75Using the this Keyword...................................................................................................................................76Using the transient Keyword...........................................................................................................................76Using the with sharing or without sharing Keywords......................................................................................77

    Annotations.................................................................................................................................................................78Deprecated Annotation...................................................................................................................................79Future Annotation...........................................................................................................................................79IsTest Annotation............................................................................................................................................80ReadOnly Annotation.....................................................................................................................................83RemoteAction Annotation..............................................................................................................................83TestVisible Annotation....................................................................................................................................84Apex REST Annotations................................................................................................................................84

    Classes and Casting.....................................................................................................................................................86Classes and Collections....................................................................................................................................87Collection Casting...........................................................................................................................................87

    Differences Between Apex Classes and Java Classes...................................................................................................88

    ii

    Table of Contents

  • Class Definition Creation............................................................................................................................................89Naming Conventions.......................................................................................................................................90Name Shadowing.............................................................................................................................................90

    Namespace Prefix........................................................................................................................................................91Using the System Namespace..........................................................................................................................91Namespace, Class, and Variable Name Precedence.........................................................................................92Type Resolution and System Namespace for Types........................................................................................93

    Apex Code Versions....................................................................................................................................................93Setting the Salesforce API Version for Classes and Triggers..........................................................................94Setting Package Versions for Apex Classes and Triggers................................................................................95

    Lists of Custom Types and Sorting.............................................................................................................................95Using Custom Types in Map Keys and Sets...............................................................................................................95

    Chapter 7: Working with Data in Apex.......................................................................................98sObject Types..............................................................................................................................................................99

    Accessing sObject Fields................................................................................................................................100Validating sObjects and Fields ......................................................................................................................101

    Adding and Retrieving Data......................................................................................................................................101DML.........................................................................................................................................................................102

    DML Statements vs. Database Class Methods.............................................................................................102DML Operations As Atomic Transactions...................................................................................................103How DML Works.........................................................................................................................................103DML Operations...........................................................................................................................................104DML Exceptions and Error Handling..........................................................................................................114More About DML........................................................................................................................................115Locking Records............................................................................................................................................124

    SOQL and SOSL Queries........................................................................................................................................125Working with SOQL and SOSL Query Results...........................................................................................127Accessing sObject Fields Through Relationships..........................................................................................127Understanding Foreign Key and Parent-Child Relationship SOQL Queries...............................................129Working with SOQL Aggregate Functions..................................................................................................129Working with Very Large SOQL Queries....................................................................................................130Using SOQL Queries That Return One Record...........................................................................................132Improving Performance by Not Searching on Null Values............................................................................132Working with Polymorphic Relationships in SOQL Queries.......................................................................133Using Apex Variables in SOQL and SOSL Queries.....................................................................................134Querying All Records with a SOQL Statement............................................................................................135

    SOQL For Loops......................................................................................................................................................136SOQL For Loops Versus Standard SOQL Queries......................................................................................136SOQL For Loop Formats.............................................................................................................................136

    sObject Collections....................................................................................................................................................138Lists of sObjects.............................................................................................................................................138Sorting Lists of sObjects................................................................................................................................139Expanding sObject and List Expressions.......................................................................................................142Sets of Objects...............................................................................................................................................142

    iii

    Table of Contents

  • Maps of sObjects...........................................................................................................................................143Dynamic Apex...........................................................................................................................................................145

    Understanding Apex Describe Information...................................................................................................145Using Field Tokens........................................................................................................................................147Understanding Describe Information Permissions........................................................................................148Describing sObjects Using Schema Method.................................................................................................149Describing Tabs Using Schema Methods......................................................................................................149Accessing All sObjects...................................................................................................................................150Accessing All Data Categories Associated with an sObject...........................................................................151Dynamic SOQL............................................................................................................................................155Dynamic SOSL.............................................................................................................................................156Dynamic DML..............................................................................................................................................157

    Apex Security and Sharing........................................................................................................................................159Enforcing Sharing Rules................................................................................................................................159Enforcing Object and Field Permissions.......................................................................................................161Class Security.................................................................................................................................................162Understanding Apex Managed Sharing.........................................................................................................162Security Tips for Apex and Visualforce Development...................................................................................174

    Custom Settings........................................................................................................................................................180

    Ways to Invoke Apex........................................................................................................................182

    Chapter 8: Invoking Apex........................................................................................................182Anonymous Blocks....................................................................................................................................................183Triggers.....................................................................................................................................................................184

    Bulk Triggers.................................................................................................................................................185Trigger Syntax...............................................................................................................................................185Trigger Context Variables.............................................................................................................................186Context Variable Considerations...................................................................................................................188Common Bulk Trigger Idioms......................................................................................................................189Defining Triggers..........................................................................................................................................190Triggers and Merge Statements.....................................................................................................................192Triggers and Recovered Records....................................................................................................................192Triggers and Order of Execution...................................................................................................................193Operations that Don't Invoke Triggers.........................................................................................................195Entity and Field Considerations in Triggers.................................................................................................196Trigger Exceptions........................................................................................................................................197Trigger and Bulk Request Best Practices.......................................................................................................198

    Asynchronous Apex...................................................................................................................................................199Future Methods.............................................................................................................................................199Apex Scheduler..............................................................................................................................................201Batch Apex....................................................................................................................................................207

    Web Services.............................................................................................................................................................218Exposing Apex Methods as SOAP Web Services.........................................................................................218Exposing Apex Classes as REST Web Services............................................................................................220

    iv

    Table of Contents

  • Apex Email Service....................................................................................................................................................229Using the InboundEmail Object....................................................................................................................230

    Visualforce Classes.....................................................................................................................................................231Invoking Apex Using JavaScript................................................................................................................................232

    JavaScript Remoting......................................................................................................................................232Apex in AJAX................................................................................................................................................232

    Chapter 9: Apex Transactions and Governor Limits..................................................................234Apex Transactions.....................................................................................................................................................235Understanding Execution Governors and Limits......................................................................................................236Using Governor Limit Email Warnings....................................................................................................................242Running Apex Within Governor Execution Limits..................................................................................................242

    Chapter 10: Using Salesforce Features with Apex......................................................................245Working with Chatter in Apex.................................................................................................................................246

    Chatter in Apex Quick Start..........................................................................................................................247Working with Feeds and Feed Items.............................................................................................................251Using ConnectApi Input and Output Classes...............................................................................................256Accessing ConnectApi Data in Communities and Portals............................................................................256Understanding Limits for ConnectApi Classes.............................................................................................257Serializing and Deserializing ConnectApi Obejcts........................................................................................257ConnectApi Versioning and Equality Checking...........................................................................................257Casting ConnectApi Objects.........................................................................................................................258Wildcards.......................................................................................................................................................258Testing ConnectApi Code.............................................................................................................................259Differences Between ConnectApi Classes and Other Apex Classes..............................................................260

    Approval Processing..................................................................................................................................................261Apex Approval Processing Example..............................................................................................................262

    Outbound Email........................................................................................................................................................262Inbound Email...........................................................................................................................................................265Knowledge Management...........................................................................................................................................265Publisher Actions.......................................................................................................................................................265Force.com Sites..........................................................................................................................................................266Rewriting URLs for Force.com Sites.........................................................................................................................266Support Classes..........................................................................................................................................................272Visual Workflow........................................................................................................................................................273Passing Data to a Flow Using the Process.Plugin Interface......................................................................................274

    Implementing the Process.Plugin Interface...................................................................................................274Using the Process.PluginRequest Class.........................................................................................................276Using the Process.PluginResult Class............................................................................................................276Using the Process.PluginDescribeResult Class..............................................................................................277Process.Plugin Data Type Conversions.........................................................................................................279Sample Process.Plugin Implementation for Lead Conversion.......................................................................279

    Communities.............................................................................................................................................................284Zones.........................................................................................................................................................................285

    v

    Table of Contents

  • Chapter 11: Integration and Apex Utilities................................................................................286Invoking Callouts Using Apex...................................................................................................................................287

    Adding Remote Site Settings........................................................................................................................287SOAP Services: Defining a Class from a WSDL Document........................................................................287Invoking HTTP Callouts..............................................................................................................................299Using Certificates..........................................................................................................................................306Callout Limits and Limitations.....................................................................................................................308

    JSON Support...........................................................................................................................................................309Roundtrip Serialization and Deserialization..................................................................................................310JSON Generator............................................................................................................................................312JSON Parsing................................................................................................................................................313

    XML Support............................................................................................................................................................315Reading and Writing XML Using Streams...................................................................................................315Reading and Writing XML Using the DOM...............................................................................................318

    Securing Your Data...................................................................................................................................................321Encoding Your Data..................................................................................................................................................323Using Patterns and Matchers.....................................................................................................................................323

    Using Regions................................................................................................................................................325Using Match Operations...............................................................................................................................325Using Bounds................................................................................................................................................325Understanding Capturing Groups.................................................................................................................326Pattern and Matcher Example.......................................................................................................................326

    Finishing Touches............................................................................................................................328

    Chapter 12: Debugging Apex...................................................................................................328Understanding the Debug Log..................................................................................................................................329

    Working with Logs in the Developer Console..............................................................................................333Debugging Apex API Calls...........................................................................................................................341

    Exceptions in Apex....................................................................................................................................................342Exception Statements....................................................................................................................................343Exception Handling Example........................................................................................................................344Built-In Exceptions and Common Methods.................................................................................................346Catching Different Exception Types.............................................................................................................349Creating Custom Exceptions.........................................................................................................................350

    Chapter 13: Testing Apex.........................................................................................................354Understanding Testing in Apex.................................................................................................................................355What to Test in Apex................................................................................................................................................355What are Apex Unit Tests?.......................................................................................................................................356

    Accessing Private Test Class Members..........................................................................................................358Understanding Test Data..........................................................................................................................................360

    Isolation of Test Data from Organization Data in Unit Tests......................................................................360Using the isTest(SeeAllData=true) Annotation.............................................................................................361Loading Test Data.........................................................................................................................................363

    vi

    Table of Contents

  • Common Test Utility Classes for Test Data Creation..................................................................................364Running Unit Test Methods.....................................................................................................................................365

    Using the runAs Method...............................................................................................................................368Using Limits, startTest, and stopTest...........................................................................................................369Adding SOSL Queries to Unit Tests............................................................................................................370

    Testing Best Practices................................................................................................................................................370Testing Example........................................................................................................................................................371

    Chapter 14: Deploying Apex....................................................................................................376Using Change Sets To Deploy Apex.........................................................................................................................377Using the Force.com IDE to Deploy Apex...............................................................................................................377Using the Force.com Migration Tool........................................................................................................................377

    Understanding deploy....................................................................................................................................379Understanding retrieveCode..........................................................................................................................380Understanding runTests()..............................................................................................................................382

    Using SOAP API to Deploy Apex............................................................................................................................382

    Chapter 15: Distributing Apex Using Managed Packages...........................................................383What is a Package?....................................................................................................................................................384Package Versions.......................................................................................................................................................384Deprecating Apex......................................................................................................................................................384Behavior in Package Versions....................................................................................................................................385

    Versioning Apex Code Behavior....................................................................................................................385Apex Code Items that Are Not Versioned....................................................................................................386Testing Behavior in Package Versions...........................................................................................................386

    Chapter 16: Reference.......................................................................................................................389DML Operations..................................................................................................................................................................390

    DML Statements......................................................................................................................................................390Insert Statement.............................................................................................................................................390Update Statement..........................................................................................................................................391Upsert Statement...........................................................................................................................................391Delete Statement...........................................................................................................................................392Undelete Statement.......................................................................................................................................393Merge Statement...........................................................................................................................................393Bulk DML Exception Handling...................................................................................................................394

    ApexPages Namespace..........................................................................................................................................................394Action Class..............................................................................................................................................................395

    Action Instance Methods..............................................................................................................................396Component Class......................................................................................................................................................397

    Dynamic Component Properties...................................................................................................................397IdeaStandardController Class....................................................................................................................................398

    IdeaStandardController Instance Methods....................................................................................................400IdeaStandardSetController Class...............................................................................................................................400

    IdeaStandardSetController Instance Methods...............................................................................................403

    vii

    Table of Contents

  • KnowledgeArticleVersionStandardController Class.................................................................................................404KnowledgeArticleVersionStandardController Instance Methods.................................................................405

    Message Class............................................................................................................................................................406Message Instance Methods............................................................................................................................407

    StandardController Class..........................................................................................................................................409StandardController Instance Methods..........................................................................................................410

    StandardSetController Class.....................................................................................................................................413StandardSetController Instance Methods.....................................................................................................415

    Approval Namespace.............................................................................................................................................................422ProcessRequest Class.................................................................................................................................................422

    ProcessRequest Instance Methods.................................................................................................................423ProcessResult Class...................................................................................................................................................424

    ProcessResult Instance Methods...................................................................................................................425ProcessSubmitRequest Class.....................................................................................................................................427

    ProcessSubmitRequest Instance Methods.....................................................................................................427ProcessWorkitemRequest Class................................................................................................................................428

    ProcessWorkitemRequest Instance Methods................................................................................................428Auth Namespace...................................................................................................................................................................430

    AuthToken Class.......................................................................................................................................................430AuthToken Instance Methods.......................................................................................................................430

    RegistrationHandler Interface...................................................................................................................................431RegistrationHandler Instance Methods.........................................................................................................432Storing User Information and Getting Access Tokens..................................................................................433Auth.RegistrationHandler Example Implementation...................................................................................434

    UserData Class..........................................................................................................................................................435UserData Properties.......................................................................................................................................435

    ChatterAnswers Namespace..................................................................................................................................................438AccountCreator Interface..........................................................................................................................................439

    AccountCreator Instance Methods................................................................................................................439AccountCreator Example Implementation....................................................................................................440

    ConnectApi Namespace........................................................................................................................................................440Chatter Class.............................................................................................................................................................442

    deleteSubscription(String, String).................................................................................................................442getFollowers(String, String)...........................................................................................................................443getFollowers(String, String, Integer, Integer)................................................................................................443getSubscription(String, String)......................................................................................................................444

    ChatterFavorites Class...............................................................................................................................................445addFavorite(String, String, String)................................................................................................................446addRecordFavorite(String, String, String).....................................................................................................447deleteFavorite(String, String, String).............................................................................................................447getFavorite(String, String, String).................................................................................................................448getFavorites(String, String)...........................................................................................................................448getFeedItems(String, String, String).............................................................................................................449getFeedItems(String, String, String, String, Integer, ConnectApi.FeedSortOrder).....................................450

    viii

    Table of Contents

  • getFeedItems(String, String, String, Integer, String, Integer, FeedSortOrder).............................................451setTestGetFeedItems(String, String, String, ConnectApi.FeedItemPage)...................................................452setTestGetFeedItems(String, String, String, String, Integer, FeedSortOrder,

    ConnectApi.FeedItemPage)....................................................................................................................452setTestGetFeedItems(String, String, String, Integer, String, Integer, FeedSortOrder,

    ConnectApi.FeedItemPage)....................................................................................................................453updateFavorite(String, String, String, Boolean)............................................................................................455

    ChatterFeeds Class....................................................................................................................................................455deleteComment(String, String).....................................................................................................................461deleteFeedItem(String, String)......................................................................................................................462deleteLike(String, String)..............................................................................................................................462getComment(String, String)..........................................................................................................................463getCommentsForFeedItem(String, String)...................................................................................................463getCommentsForFeedItem(String, String, String, Integer)..........................................................................464getFeed(String, ConnectApi.FeedType).......................................................................................................465getFeed(String, ConnectApi.FeedType, ConnectApi.FeedSortOrder).........................................................465getFeed(String, ConnectApi.FeedType, String)............................................................................................466getFeed(String, ConnectApi.FeedType, String, ConnectApi.FeedSortOrder).............................................466getFeedItem(String, String)...........................................................................................................................467getFeedItemsFromFeed(String, ConnectApi.FeedType)..............................................................................468getFeedItemsFromFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedSortOrder)......468getFeedItemsFromFeed(String, ConnectApi.FeedType, Integer, ConnectApi.FeedDensity, String, Integer,

    ConnectApi.FeedSortOrder)...................................................................................................................469getFeedItemsFromFeed(String, ConnectApi.FeedType, String)..................................................................471getFeedItemsFromFeed(String, ConnectApi.FeedType, String, String, Integer,

    ConnectApi.FeedSortOrder)...................................................................................................................471getFeedItemsFromFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedDensity, String,

    Integer, ConnectApi.FeedSortOrder)......................................................................................................472getFeedItemsFromFilterFeed(String, String, String)....................................................................................474getFeedItemsFromFilterFeed(String, String, String, String, Integer, ConnectApi.FeedSortOrder)............474getFeedItemsFromFilterFeed(String, String, String, Integer, ConnectApi.FeedDensity, String, Integer,

    ConnectApi.FeedSortOrder)...................................................................................................................476getFeedPoll(String, String)............................................................................................................................477getFilterFeed(String, String, String)..............................................................................................................477getFilterFeed(String, String, String, ConnectApi.FeedType).......................................................................478getLike(String, String)...................................................................................................................................479getLikesForComment(String, String)...........................................................................................................479getLikesForComment(String, String, Integer, Integer)................................................................................480getLikesForFeedItem(String, String)............................................................................................................481getLikesForFeedItem(String, String, Integer, Integer).................................................................................481isModified(String, ConnectApi.FeedType, String, String)...........................................................................482likeComment(String, String).........................................................................................................................483likeFeedItem(String, String)..........................................................................................................................483postComment(String, String, String)............................................................................................................484

    ix

    Table of Contents

  • postComment(String, String, ConnectApi.CommentInput, ConnectApi.BinaryInput)..............................484postFeedItem(String, ConnectApi.FeedType, String, String)......................................................................486postFeedItem(String, ConnectApi.FeedType, String, ConnectApi.FeedItemInput,

    ConnectApi.BinaryInput)........................................................................................................................487searchFeedItems(String, String)....................................................................................................................489searchFeedItems(String, String, ConnectApi.FeedSortOrder).....................................................................489searchFeedItems(String, String, String, Integer)...........................................................................................490searchFeedItems(String, String, String, Integer, ConnectApi.FeedSortOrder)............................................491searchFeedItems(String, String, Integer, String, Integer, ConnectApi.FeedSortOrder)...............................491searchFeedItemsInFeed(String, ConnectApi.FeedType, String)..................................................................492searchFeedItemsInFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedSortOrder,

    String)......................................................................................................................................................493searchFeedItemsInFeed(String, ConnectApi.FeedType, Integer, ConnectApi.FeedDensity, String, Integer,

    ConnectApi.FeedSortOrder, String).......................................................................................................494searchFeedItemsInFeed(String, ConnectApi.FeedType, String, String)......................................................495searchFeedItemsInFeed(String, ConnectApi.FeedType, String, String, Integer, ConnectApi.FeedSortOrder,

    String)......................................................................................................................................................496searchFeedItemsInFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedDensity, String,

    Integer, ConnectApi.FeedSortOrder, String)..........................................................................................497searchFeedItemsInFilterFeed(String, String, String, String).........................................................................499searchFeedItemsInFilterFeed(String, ConnectApi.FeedType, String, String, String, Integer,

    ConnectApi.FeedSortOrder, String).......................................................................................................499searchFeedItemsInFilterFeed(String, ConnectApi.FeedType, String, String, Integer,

    ConnectApi.FeedDensity, String, Integer, ConnectApi.FeedSortOrder, String)...................................501setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, ConnectApi.FeedItemPage)...................502setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, String, Integer,

    ConnectApi.FeedSortOrder, ConnectApi.FeedItemPage)......................................................................503setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, Integer, ConnectApi.FeedDensity, String,

    Integer, ConnectApi.FeedSortOrder, ConnectApi.FeedItemPage)........................................................504setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, String, ConnectApi.FeedItemPage)........505setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, String, String, Integer,

    ConnectApi.FeedSortOrder, ConnectApi.FeedItemPage)......................................................................506setTestGetFeedItemsFromFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedDensity,

    String, Integer, ConnectApi.FeedSortOrder, ConnectApi.FeedItemPage)............................................507setTestGetFeedItemsFromFilterFeed(String, String, String, ConnectApi.FeedItemPage)..........................509setTestGetFeedItemsFromFilterFeed(String, String, String, String, Integer, ConnectApi.FeedSortOrder,

    ConnectApi.FeedItemPage)....................................................................................................................509setTestGetFeedItemsFromFilterFeed(String, String, String, Integer, ConnectApi.FeedDensity, String,

    Integer, ConnectApi.FeedSortOrder, ConnectApi.FeedItemPage)........................................................511setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, String, ConnectApi.FeedItemPage)........512setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedSortOrder,

    String, ConnectApi.FeedItemPage).........................................................................................................513setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, Integer, ConnectApi.FeedDensity, String,

    Integer, ConnectApi.FeedSortOrder, String, ConnectApi.FeedItemPage)............................................514

    x

    Table of Contents

  • setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, String, String,ConnectApi.FeedItemPage)....................................................................................................................515

    setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, String, String, Integer,ConnectApi.FeedSortOrder, String, ConnectApi.FeedItemPage)..........................................................516

    setTestSearchFeedItemsInFeed(String, ConnectApi.FeedType, String, Integer, ConnectApi.FeedDensity,String, Integer, ConnectApi.FeedSortOrder, String, ConnectApi.FeedItemPage).................................518

    setTestSearchFeedItemsInFilterFeed(String, String, String, String, ConnectApi.FeedItemPage)...............519setTestSearchFeedItemsInFilterFeed(String, ConnectApi.FeedType, String, String, String, Integer,

    ConnectApi.FeedSortOrder, String, ConnectApi.FeedItemPage)..........................................................520setTestSearchFeedItemsInFilterFeed(String, ConnectApi.FeedType, String, String, Integer,

    ConnectApi.FeedDensity, String, Integer, ConnectApi.FeedSortOrder, String,ConnectApi.FeedItemPage)....................................................................................................................521

    shareFeedItem(String, ConnectApi.FeedType, String, String).....................................................................523updateBookmark(String, String, Boolean)....................................................................................................524voteOnFeedPoll(String, String, String).........................................................................................................525

    ChatterGroups Class.................................................................................................................................................525addMember(String, String, String)...............................................................................................................527addMemberWithRole(String, String, String, ConnectApi.GroupMembershipType)..................................528createGroup(String, ConnectApi.ChatterGroupInput).................................................................................529deleteMember(String, String)........................................................................................................................529deletePhoto(String, String)............................................................................................................................530getGroup(String, String)...............................................................................................................................530getGroupMembershipRequest(String, String)..............................................................................................531getGroupMembershipRequests(String, String).............................................................................................531getGroupMembershipRequests(String, String, ConnectApi.GroupMembershipRequestStatus).................532getGroups(String)..........................................................................................................................................533getGroups(String, Integer, Integer)...............................................................................................................533getGroups(String, Integer, Integer, ConnectApi.GroupArchiveStatus)........................................................534getMember(String, String)............................................................................................................................535getMembers(String, String)...........................................................................................................................535getMembers(String, String, Integer, Integer)................................................................................................536getMyChatterSettings(String, String)...........................................................................................................536getPhoto(String, String)................................................................................................................................537requestGroupMembership(String, String).....................................................................................................537searchGroups(String, String).........................................................................................................................538searchGroups(String, String, Integer, Integer)..............................................................................................538searchGroups(String, String, ConnectApi.GroupArchiveStatus, Integer, Integer).......................................539setPhoto(String, String, String, Integer)........................................................................................................540setPhoto(String, String, ConnectApi.BinaryInput).......................................................................................541setPhotoWithAttributes(String, String, ConnectApi.PhotoInput)...............................................................542setPhotoWithAttributes(String, String, ConnectApi.PhotoInput, ConnectApi.BinaryInput).....................543setTestSearchGroups(String, String, ConnectApi.ChatterGroupPage)........................................................545setTestSearchGroups(String, String, Integer, Integer, ConnectApi.ChatterGroupPage).............................544

    xi

    Table of Contents

  • setTestSearchGroups(String, String, ConnectApi.GroupArchiveStatus, Integer, Integer,ConnectApi.ChatterGroupPage).............................................................................................................545

    updateGroup(String, String, ConnectApi.ChatterGroupInput)...................................................................546updateGroupMember(String, String, ConnectApi.GroupMembershipType)..............................................547updateMyChatterSettings(String, String, ConnectApi.GroupEmailFrequency)..........................................548updateRequestStatus(String, String, ConnectApi.GroupMembershipRequestStatus)..................................548

    ChatterMessages Class..............................................................................................................................................549getConversation(String).................................................................................................................................551getConversation(String, String, Integer).......................................................................................................551getConversations().........................................................................................................................................552getConversations(String, Integer)..................................................................................................................552getMessage(String)........................................................................................................................................553getMessages().................................................................................................................................................553getMessages(String, Integer).........................................................................................................................553getUnreadCount()..........................................................................................................................................554markConversationRead(String, Boolean)......................................................................................................554replyToMessage(String, String).....................................................................................................................555searchConversation(String, String)................................................................................................................555searchConversation(String, String, String)....................................................................................................556searchConversations(String)..........................................................................................................................556searchConversations(String, Integer, String).................................................................................................557searchMessages(String)..................................................................................................................................557searchMessages(String, Integer, String)........................................................................................................558sendMessage(String, String)..........................................................................................................................558

    ChatterUsers Class....................................................................................................................................................559deletePhoto(String, String)............................................................................................................................561follow(String, String, String).........................................................................................................................562getChatterSettings(String, String).................................................................................................................562getFollowers(String, String)...........................................................................................................................563getFollowers(String, String, Integer, Integer)................................................................................................563getFollowings(String, String)........................................................................................................................564getFollowings(String, String, Integer)...........................................................................................................564getFollowings(String, String, Integer, Integer)..............................................................................................565getFollowings(String, String, String).............................................................................................................566getFollowings(String, String, String, Integer)...............................................................................................566getFollowings(String, String, String, Integer, Integer)..................................................................................567getGroups(String, String)..............................................................................................................................568getGroups(String, String, Integer, Integer)...................................................................................................568getPhoto(String, String)................................................................................................................................569getUser(String, String)...................................................................................................................................570getUsers(String).............................................................................................................................................570getUsers(String, Integer, Integer)..................................................................................................................571searchUsers(String, String)............................................................................................................................571searchUsers(String, String, Integer, Integer).................................................................................................572

    xii

    Table of Contents

  • searchUsers(String, String, String, Integer, Integer)......................................................................................572setPhoto(String, String, String, Integer)........................................................................................................573setPhoto(String, String, ConnectApi.BinaryInput).......................................................................................574setPhotoWithAttributes(String, String, ConnectApi.Photo)........................................................................575setPhotoWithAttributes(String, String, ConnectApi.Photo, ConnectApi.BinaryInput)..............................575setTestSearchUsers(String, String, ConnectApi.UserPage)..........................................................................576setTestSearchUsers(String, String, Integer, Integer, ConnectApi.UserPage)...............................................577setTestSearchUsers(String, String, String, Integer, Integer, ConnectApi.UserPage)....................................578updateChatterSettings(String, String, ConnectApi.GroupEmailFrequency)................................................578updateUser(String, String, ConnectApi.UserInput)......................................................................................579

    Communities Class....................................................................................................................................................580getCommunities()..........................................................................................................................................580getCommunities(ConnectApi.CommunityStatus)........................................................................................581getCommunity(String)..................................................................................................................................581

    CommunityModeration Class...................................................................................................................................582addFlagToComment(String, String).............................................................................................................582addFlagToFeedItem(String, String)..............................................................................................................583getFlagsOnComment(String, String)............................................................................................................583getFlagsOnFeedItem(String, String).............................................................................................................584removeFlagsOnComment(String, String, String).........................................................................................584removeFlagsOnFeedItem(String, String, String)..........................................................................................585

    Organization Class....................................................................................................................................................586getSettings()...................................................................................................................................................586

    Mentions Class..........................................................................................................................................................586getMentionCompletions(String, String, String)............................................................................................586getMentionCompletions(String, String, String, ConnectApi.MentionCompletionType, Integer,

    Integer).....................................................................................................................................................587getMentionValidations(String, String, List, ConnectApi.FeedItemVisibilityType).......................588

    Records Class.............................................................................................................................................................589getMotif(String, String).................................................................................................................................589

    Topics Class...............................................................................................................................................................590assignTopic(String, String, String)................................................................................................................592assignTopicByName(String, String, String)..................................................................................................592deleteTopic(String, String)............................................................................................................................593getGroupsRecentlyTalkingAboutTopic(String, String)................................................................................593getRecentlyTalkingAboutTopicsForGroup(String, String)...........................................................................594getRecentlyTalkingAboutTopicsForUser(String, String)..............................................................................594getRelatedTopics(String, String)...................................................................................................................595getTopic(String, String).................................................................................................................................595getTopics(String, String)...............................................................................................................................596getTopics(String)...........................................................................................................................................596getTopics(String, ConnectApi.TopicSort)....................................................................................................597getTopics(String, Integer, Integer)................................................................................................................597getTopics(String, Integer, Integer, ConnectApi.TopicSort).........................................................................598

    xiii

    Table of Contents

  • getTopics(String, String, ConnectApi.TopicSort)........................................................................................599getTopics(String, String, Integer, Integer)....................................................................................................599getTopics(String, String, Integer, Integer, ConnectApi.TopicSort).............................................................600getTopicSuggestions(String, String, Integer)................................................................................................601getTopicSuggestions(String, String)..............................................................................................................601getTopicSuggestionsForText(String, String, Integer)...................................................................................602getTopicSuggestionsForText(String, String).................................................................................................603getTrendingTopics(String)............................................................................................................................603getTrendingTopics(String, Integer)...............................................................................................................604unassignTopic(String, String, String)............................................................................................................604updateTopic(String, String, ConnectApi.TopicInput)..................................................................................605

    UserProfiles Class......................................................................................................................................................605getUserProfile(String, String)........................................................................................................................606

    Zones Class...............................................................................................................................................................606getZone(String, String).................................................................................................................................607getZones(String)............................................................................................................................................607getZones(String, Integer, Integer).................................................................................................................607searchInZone(String, String, String, ConnectApi.ZoneSearchResultType).................................................608searchInZone(String, String, String, ConnectApi.ZoneSearchResultType, String, Integer)........................609

    ConnectApi Input Classes.........................................................................................................................................610ConnectApi Output Classes......................................................................................................................................616ConnectApi Enums...................................................................................................................................................659ConnectApi Exceptions.............................................................................................................................................667

    Database Namespace.............................................................................................................................................................667Batchable Interface....................................................................................................................................................668

    Batchable Instance Methods..........................................................................................................................669BatchableContext Interface.......................................................................................................................................670

    BatchableContext Instance Methods.............................................................................................................671DeletedRecord Class.................................................................................................................................................671

    DeletedRecord Instance Methods.................................................................................................................672DeleteResult Class.....................................................................................................................................................673

    DeleteResult Instance Methods.....................................................................................................................673DMLOptions Class...................................................................................................................................................675

    DmlOptions Properties.................................................................................................................................675DmlOptions.AssignmentRuleHeader Class..............................................................................................................677

    DmlOptions.AssignmentRuleHeader Properties..........................................................................................678DmlOptions.EmailHeader Class...............................................................................................................................678

    DmlOptions.EmailHeader Properties...........................................................................................................679EmptyRecycleBinResult Class...................................................................................................................................681

    EmptyRecycleBinResult Instance Methods...................................................................................................681Error Class.................................................................................................................................................................682

    Error Instance Methods.................................................................................................................................682GetDeletedResult Class.............................................................................................................................................683

    Ge