salesforce apex language reference

1732
Version 31.0: Summer 14 Force.com Apex Code Developer's Guide Last updated: August 15, 2014 © Copyright 20002014 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.

Upload: wawankn

Post on 29-Jan-2016

252 views

Category:

Documents


3 download

TRANSCRIPT

  • Version 31.0: Summer 14

    Force.com Apex Code Developer's Guide

    Last updated: August 15, 2014

    Copyright 20002014 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.....................................................................................................................................6What'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.............................................................................................................................................................14Writing Apex Using Development Environments......................................................................................................16Writing Tests..............................................................................................................................................................17Deploying Apex to a Sandbox Organization...............................................................................................................17Deploying Apex to a Salesforce Production Organization..........................................................................................18Adding Apex Code to a Force.com AppExchange App.............................................................................................18

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

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

    Writing Apex.....................................................................................................................................25

    Chapter 4: Data Types and Variables..........................................................................................25Data Types..................................................................................................................................................................26Primitive Data Types...................................................................................................................................................26Collections...................................................................................................................................................................29

    Lists.................................................................................................................................................................29Sets..................................................................................................................................................................32Maps................................................................................................................................................................32Parameterized Typing......................................................................................................................................33

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

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

    i

    Table of Contents

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

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

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

    Do-While Loops.............................................................................................................................................50While Loops....................................................................................................................................................50For Loops........................................................................................................................................................50

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

    Apex Class Definition.....................................................................................................................................54Class Variables.................................................................................................................................................55Class Methods.................................................................................................................................................56Using Constructors..........................................................................................................................................58Access Modifiers..............................................................................................................................................59Static and Instance...........................................................................................................................................60Apex Properties...............................................................................................................................................63Extending a Class............................................................................................................................................66Extended Class Example.................................................................................................................................67

    Understanding Interfaces.............................................................................................................................................70Custom Iterators..............................................................................................................................................71

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

    Annotations.................................................................................................................................................................78Deprecated Annotation...................................................................................................................................78Future 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....................................................................................................................................................94Setting 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.......................................................................................99sObject Types............................................................................................................................................................100

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

    Adding and Retrieving Data.....................................................................................................................................102DML.........................................................................................................................................................................103

    DML Statements vs. Database Class Methods.............................................................................................103DML Operations As Atomic Transactions...................................................................................................104How DML Works........................................................................................................................................105DML Operations..........................................................................................................................................106DML Exceptions and Error Handling..........................................................................................................116More About DML........................................................................................................................................117Locking Records............................................................................................................................................126

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

    SOQL For Loops......................................................................................................................................................138sObject Collections....................................................................................................................................................140

    Lists of sObjects............................................................................................................................................140Sorting Lists of sObjects................................................................................................................................142Expanding sObject and List Expressions......................................................................................................144Sets of Objects...............................................................................................................................................145Maps of sObjects...........................................................................................................................................145

    Dynamic Apex...........................................................................................................................................................147

    iii

    Table of Contents

  • Understanding Apex Describe Information...................................................................................................147Using Field Tokens.......................................................................................................................................149Understanding Describe Information Permissions........................................................................................151Describing sObjects Using Schema Method.................................................................................................151Describing Tabs Using Schema Methods......................................................................................................152Accessing All sObjects...................................................................................................................................153Accessing All Data Categories Associated with an sObject..........................................................................153Dynamic SOQL............................................................................................................................................157Dynamic SOSL.............................................................................................................................................159Dynamic DML..............................................................................................................................................159

    Apex Security and Sharing........................................................................................................................................162Enforcing Sharing Rules................................................................................................................................162Enforcing Object and Field Permissions.......................................................................................................163Class Security.................................................................................................................................................164Understanding Apex Managed Sharing.........................................................................................................165Security Tips for Apex and Visualforce Development...................................................................................176

    Custom Settings........................................................................................................................................................183

    Ways to Invoke Apex........................................................................................................................185

    Chapter 8: Invoking Apex........................................................................................................185Anonymous Blocks....................................................................................................................................................186Triggers.....................................................................................................................................................................187

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

    Asynchronous Apex...................................................................................................................................................202Future Methods.............................................................................................................................................202Future Methods with Higher Limits (Pilot).................................................................................................204Apex Scheduler..............................................................................................................................................206Batch Apex....................................................................................................................................................212

    Web Services.............................................................................................................................................................224Exposing Apex Methods as SOAP Web Services.........................................................................................224Exposing Apex Classes as REST Web Services............................................................................................226

    Apex Email Service...................................................................................................................................................235

    iv

    Table of Contents

  • Using the InboundEmail Object...................................................................................................................236Visualforce Classes....................................................................................................................................................237Invoking Apex Using JavaScript................................................................................................................................238

    JavaScript Remoting......................................................................................................................................238Apex in AJAX...............................................................................................................................................239

    Chapter 9: Apex Transactions and Governor Limits..................................................................241Apex Transactions.....................................................................................................................................................242Understanding Execution Governors and Limits......................................................................................................243Using Governor Limit Email Warnings...................................................................................................................249Running Apex within Governor Execution Limits...................................................................................................249

    Chapter 10: Using Salesforce Features with Apex......................................................................252Working with Chatter in Apex.................................................................................................................................253

    Chatter in Apex Quick Start..........................................................................................................................254Chatter in Apex Examples.............................................................................................................................258Using ConnectApi Input and Output Classes...............................................................................................262Accessing ConnectApi Data in Communities and Portals............................................................................262Working with Feeds and Feed Elements.......................................................................................................263Understanding Limits for ConnectApi Classes.............................................................................................272Serializing and Deserializing ConnectApi Obejcts........................................................................................272ConnectApi Versioning and Equality Checking...........................................................................................272Casting ConnectApi Objects.........................................................................................................................273Wildcards.......................................................................................................................................................273Testing ConnectApi Code............................................................................................................................274Differences Between ConnectApi Classes and Other Apex Classes..............................................................275

    Approval Processing..................................................................................................................................................276Apex Approval Processing Example..............................................................................................................277

    Outbound Email.......................................................................................................................................................277Inbound Email..........................................................................................................................................................280Knowledge Management...........................................................................................................................................280Actions......................................................................................................................................................................280Force.com Sites.........................................................................................................................................................281Rewriting URLs for Force.com Sites........................................................................................................................281Support Classes.........................................................................................................................................................287Visual Workflow.......................................................................................................................................................288Passing Data to a Flow Using the Process.Plugin Interface......................................................................................289

    Implementing the Process.Plugin Interface...................................................................................................290Using the Process.PluginRequest Class.........................................................................................................291Using the Process.PluginResult Class............................................................................................................292Using the Process.PluginDescribeResult Class..............................................................................................292Process.Plugin Data Type Conversions.........................................................................................................294Sample Process.Plugin Implementation for Lead Conversion.......................................................................294

    Communities.............................................................................................................................................................300Zones.........................................................................................................................................................................300

    v

    Table of Contents

  • Analytics API via Apex.............................................................................................................................................301Requirements and Limitations......................................................................................................................301Run Reports...................................................................................................................................................302List Asynchronous Runs of a Report.............................................................................................................303Get Report Metadata.....................................................................................................................................303Get Report Data............................................................................................................................................304Filter Reports.................................................................................................................................................305Decode the Fact Map....................................................................................................................................306Test Reports..................................................................................................................................................308

    Chapter 11: Integration and Apex Utilities................................................................................311Invoking Callouts Using Apex..................................................................................................................................312

    Adding Remote Site Settings........................................................................................................................312SOAP Services: Defining a Class from a WSDL Document........................................................................312Invoking HTTP Callouts..............................................................................................................................323Using Certificates..........................................................................................................................................331Callout Limits and Limitations.....................................................................................................................333

    JSON Support...........................................................................................................................................................334Roundtrip Serialization and Deserialization..................................................................................................335JSON Generator............................................................................................................................................337JSON Parsing................................................................................................................................................338

    XML Support............................................................................................................................................................340Reading and Writing XML Using Streams...................................................................................................340Reading and Writing XML Using the DOM...............................................................................................343

    Securing Your Data...................................................................................................................................................346Encoding Your Data.................................................................................................................................................348Using Patterns and Matchers....................................................................................................................................349

    Using Regions................................................................................................................................................350Using Match Operations...............................................................................................................................351Using Bounds................................................................................................................................................351Understanding Capturing Groups.................................................................................................................351Pattern and Matcher Example.......................................................................................................................352

    Finishing Touches............................................................................................................................354

    Chapter 12: Debugging Apex...................................................................................................354Understanding the Debug Log..................................................................................................................................355

    Working with Logs in the Developer Console..............................................................................................359Debugging Apex API Calls...........................................................................................................................371

    Exceptions in Apex....................................................................................................................................................372Exception Statements....................................................................................................................................373Exception Handling Example.......................................................................................................................374Built-In Exceptions and Common Methods.................................................................................................376Catching Different Exception Types.............................................................................................................380Creating Custom Exceptions.........................................................................................................................381

    vi

    Table of Contents

  • Chapter 13: Testing Apex.........................................................................................................384Understanding Testing in Apex................................................................................................................................385What to Test in Apex................................................................................................................................................385What are Apex Unit Tests?.......................................................................................................................................386

    Accessing Private Test Class Members.........................................................................................................388Understanding Test Data..........................................................................................................................................390

    Isolation of Test Data from Organization Data in Unit Tests......................................................................390Using the isTest(SeeAllData=true) Annotation............................................................................................392Loading Test Data.........................................................................................................................................393Common Test Utility Classes for Test Data Creation..................................................................................394

    Running Unit Test Methods.....................................................................................................................................395Using the runAs Method...............................................................................................................................398Using Limits, startTest, and stopTest...........................................................................................................399Adding SOSL Queries to Unit Tests............................................................................................................400

    Testing Best Practices................................................................................................................................................400Testing Example.......................................................................................................................................................402

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

    Understanding deploy....................................................................................................................................410Understanding retrieveCode..........................................................................................................................411Understanding runTests()..............................................................................................................................413

    Using SOAP API to Deploy Apex............................................................................................................................413

    Chapter 15: Distributing Apex Using Managed Packages..........................................................414What is a Package?....................................................................................................................................................415Package Versions.......................................................................................................................................................415Deprecating Apex......................................................................................................................................................415Behavior in Package Versions....................................................................................................................................416

    Versioning Apex Code Behavior...................................................................................................................416Apex Code Items that Are Not Versioned....................................................................................................417Testing Behavior in Package Versions...........................................................................................................417

    Chapter 16: Reference......................................................................................................................420Apex DML Operations.........................................................................................................................................................421

    Apex DML Statements.............................................................................................................................................421Insert Statement............................................................................................................................................422Update Statement..........................................................................................................................................422Upsert Statement...........................................................................................................................................423Delete Statement...........................................................................................................................................424Undelete Statement.......................................................................................................................................424Merge Statement...........................................................................................................................................425

    ApexPages Namespace..........................................................................................................................................................425

    vii

    Table of Contents

  • Action Class..............................................................................................................................................................426Action Constructors......................................................................................................................................427Action Methods.............................................................................................................................................428

    Component Class......................................................................................................................................................428Dynamic Component Properties...................................................................................................................428

    IdeaStandardController Class...................................................................................................................................430IdeaStandardController Methods..................................................................................................................431

    IdeaStandardSetController Class..............................................................................................................................432IdeaStandardSetController Methods.............................................................................................................434

    KnowledgeArticleVersionStandardController Class.................................................................................................435KnowledgeArticleVersionStandardController Constructors.........................................................................437KnowledgeArticleVersionStandardController Methods................................................................................437

    Message Class............................................................................................................................................................438Message Constructors....................................................................................................................................439Message Methods..........................................................................................................................................441

    StandardController Class..........................................................................................................................................442StandardController Constructors..................................................................................................................443StandardController Methods.........................................................................................................................443

    StandardSetController Class.....................................................................................................................................447StandardSetController Constructors.............................................................................................................448StandardSetController Methods....................................................................................................................449

    Approval Namespace.............................................................................................................................................................455ProcessRequest Class.................................................................................................................................................455

    ProcessRequest Methods...............................................................................................................................455ProcessResult Class...................................................................................................................................................457

    ProcessResult Methods..................................................................................................................................457ProcessSubmitRequest Class.....................................................................................................................................459

    ProcessSubmitRequest Methods...................................................................................................................459ProcessWorkitemRequest Class................................................................................................................................460

    ProcessWorkitemRequest Methods..............................................................................................................460Auth Namespace...................................................................................................................................................................462

    AuthToken Class......................................................................................................................................................462AuthToken Methods.....................................................................................................................................462

    RegistrationHandler Interface...................................................................................................................................464RegistrationHandler Methods.......................................................................................................................464Storing User Information and Getting Access Tokens..................................................................................466Auth.RegistrationHandler Example Implementation...................................................................................467

    UserData Class..........................................................................................................................................................468UserData Constructors..................................................................................................................................468UserData Properties.......................................................................................................................................469

    Canvas Namespace................................................................................................................................................................472ApplicationContext Interface....................................................................................................................................473

    ApplicationContext Methods........................................................................................................................473CanvasLifecycleHandler Interface.............................................................................................................................476

    viii

    Table of Contents

  • CanvasLifecycleHandler Methods.................................................................................................................476ContextTypeEnum Enum.........................................................................................................................................478EnvironmentContext Interface..................................................................................................................................478

    EnvironmentContext Methods.....................................................................................................................479RenderContext Interface...........................................................................................................................................484

    RenderContext Methods...............................................................................................................................484Test Class..................................................................................................................................................................486

    Test Constants...............................................................................................................................................486Test Methods................................................................................................................................................487

    Canvas Exceptions.....................................................................................................................................................489ChatterAnswers Namespace..................................................................................................................................................490

    AccountCreator Interface..........................................................................................................................................490AccountCreator Methods..............................................................................................................................490AccountCreator Example Implementation....................................................................................................491

    ConnectApi Namespace........................................................................................................................................................492Announcements Class...............................................................................................................................................493

    Announcements Methods.............................................................................................................................494Chatter Class.............................................................................................................................................................496

    Chatter Methods...........................................................................................................................................497ChatterFavorites Class...............................................................................................................................................500

    ChatterFavorites Methods.............................................................................................................................501ChatterFeeds Class....................................................................................................................................................520

    ChatterFeeds Methods..................................................................................................................................520ChatterGroups Class.................................................................................................................................................724

    ChatterGroups Methods...............................................................................................................................724ChatterMessages Class..............................................................................................................................................756

    ChatterMessages Methods............................................................................................................................756ChatterUsers Class....................................................................................................................................................779

    ChatterUsers Methods..................................................................................................................................779Communities Class...................................................................................................................................................804

    Communities Methods..................................................................................................................................804CommunityModeration Class...................................................................................................................................806

    CommunityModeration Methods.................................................................................................................806Organization Class....................................................................................................................................................817

    Organization Methods..................................................................................................................................818Mentions Class..........................................................................................................................................................818

    Mentions Methods........................................................................................................................................818RecordDetails Class...................................................................................................................................................824

    RecordDetails Methods.................................................................................................................................824Records Class............................................................................................................................................................827

    Records Methods...........................................................................................................................................827Topics Class..............................................................................................................................................................829

    Topics Methods.............................................................................................................................................830UserProfiles Class......................................................................................................................................................857

    ix

    Table of Contents

  • UserProfiles Methods....................................................................................................................................857Zones Class...............................................................................................................................................................857

    Zones Methods..............................................................................................................................................858ConnectApi Input Classes.........................................................................................................................................864

    ConnectApi.AnnouncementInput Class.......................................................................................................864ConnectApi.BinaryInput Class.....................................................................................................................865ConnectApi.CanvasAttachmentInput Class.................................................................................................865ConnectApi.ChatterGroupInput Class.........................................................................................................865ConnectApi.CommentInput Class................................................................................................................866ConnectApi.ContentAttachmentInput Class................................................................................................866ConnectApi.FeedElementInput Class...........................................................................................................867ConnectApi.FeedItemAttachmentInput Class..............................................................................................867ConnectApi.FeedItemInput Class.................................................................................................................867ConnectApi.GroupInformationInput Class..................................................................................................868ConnectApi.HashtagSegmentInput Class.....................................................................................................868ConnectApi.LinkAttachmentInput Class.....................................................................................................868ConnectApi.LinkSegmentInput Class..........................................................................................................868ConnectApi.MentionSegmentInput Class....................................................................................................869ConnectApi.MessageBodyInput Class..........................................................................................................869ConnectApi.MessageSegmentInput Class....................................................................................................869ConnectApi.NewFileAttachmentInput Class...............................................................................................869ConnectApi.PhotoInput Class......................................................................................................................870ConnectApi.PollAttachmentInput Class.......................................................................................................870ConnectApi.TextSegmentInput Class...........................................................................................................870ConnectApi.TopicInput Class.......................................................................................................................870ConnectApi.UserInput Class.........................................................................................................................871

    ConnectApi Output Classes......................................................................................................................................871ConnectApi.AbstractBundleCapability Class...............................................................................................871ConnectApi.AbstractMessageBody Class.....................................................................................................872ConnectApi.AbstractRecordField Class........................................................................................................872ConnectApi.AbstractRecordView Class........................................................................................................873ConnectApi.Actor Class................................................................................................................................873ConnectApi.ActorWithId Class....................................................................................................................874ConnectApi.Address Class............................................................................................................................874ConnectApi.Announcement..........................................................................................................................874ConnectApi.AnnouncementPage..................................................................................................................875ConnectApi.ApprovalAttachment Class.......................................................................................................875ConnectApi.ApprovalPostTemplateField Class............................................................................................876ConnectApi.BannerCapability Class.............................................................................................................876ConnectApi.BasicTemplateAttachment Class..............................................................................................876ConnectApi.BatchResult...............................................................................................................................877ConnectApi.BlankRecordField Class............................................................................................................879ConnectApi.BookmarksCapability Class......................................................................................................879ConnectApi.Bundle Class.............................................................................................................................879

    x

    Table of Contents

  • ConnectApi.CanvasTemplateAttachment Class...........................................................................................880ConnectApi.CaseComment Class.................................................................................................................880ConnectApi.ChatterActivity Class................................................................................................................881ConnectApi.ChatterConversation Class.......................................................................................................881ConnectApi.ChatterConversationPage Class................................................................................................881ConnectApi.ChatterConversationSummary Class........................................................................................882ConnectApi.ChatterGroup Class..................................................................................................................882ConnectApi.ChatterGroupDetail Class........................................................................................................883ConnectApi.ChatterGroupPage Class..........................................................................................................884ConnectApi.ChatterGroupSummary Class...................................................................................................884ConnectApi.ChatterGroupSummaryPage Class...........................................................................................884ConnectApi.ChatterLike Class.....................................................................................................................884ConnectApi.ChatterLikePage Class..............................................................................................................885ConnectApi.ChatterLikesCapability Class...................................................................................................885ConnectApi.ChatterMessage Class...............................................................................................................885ConnectApi.ChatterMessagePage Class.......................................................................................................886ConnectApi.ClientInfo Class........................................................................................................................886ConnectApi.Comment Class........................................................................................................................886ConnectApi.CommentPage Class.................................................................................................................887ConnectApi.CommentsCapability Class.......................................................................................................888ConnectApi.Community Class.....................................................................................................................888ConnectApi.CommunityPage Class..............................................................................................................889ConnectApi.ComplexSegment Class............................................................................................................889ConnectApi.CompoundRecordField Class...................................................................................................889ConnectApi.ContentAttachment Class........................................................................................................889ConnectApi.CurrencyRecordField Class.......................................................................................................891ConnectApi.DashboardComponentAttachment Class.................................................................................891ConnectApi.DateRecordField Class.............................................................................................................891ConnectApi.EmailAddress Class..................................................................................................................891ConnectApi.EmailMessage Class..................................................................................................................892ConnectApi.EntityLinkSegment Class.........................................................................................................892ConnectApi.Features Class...........................................................................................................................892ConnectApi.Feed Class.................................................................................................................................894ConnectApi.FeedBody Class.........................................................................................................................894ConnectApi.FeedDirectory Class..................................................................................................................894ConnectApi.FeedDirectoryItem Class..........................................................................................................894ConnectApi.FeedElement Class...................................................................................................................895ConnectApi.FeedElementCapabilities Class.................................................................................................897ConnectApi.FeedElementCapability Class...................................................................................................897ConnectApi.FeedElementPage Class............................................................................................................898ConnectApi.FeedFavorite Class....................................................................................................................899ConnectApi.FeedFavorites Class...................................................................................................................899ConnectApi.FeedItem Class.........................................................................................................................899ConnectApi.FeedItemAttachment Class......................................................................................................903

    xi

    Table of Contents

  • ConnectApi.FeedItemPage Class..................................................................................................................903ConnectApi.FeedItemTopicPage Class........................................................................................................904ConnectApi.FeedModifiedInfo Class...........................................................................................................904ConnectApi.FeedPoll Class...........................................................................................................................904ConnectApi.FeedPollChoice Class...............................................................................................................905ConnectApi.FieldChangeSegment Class......................................................................................................905ConnectApi.FieldChangeNameSegment Class.............................................................................................905ConnectApi.FieldChangeValueSegment Class.............................................................................................905ConnectApi.File Class...................................................................................................................................905ConnectApi.FileSummary Class...................................................................................................................907ConnectApi.FollowerPage Class...................................................................................................................908ConnectApi.FollowingCounts Class.............................................................................................................908ConnectApi.FollowingPage Class.................................................................................................................908ConnectApi.GenericBundleCapability Class................................................................................................909ConnectApi.GlobalInfluence Class...............................................................................................................909ConnectApi.GroupChatterSettings Class.....................................................................................................909ConnectApi.GroupInformation Class...........................................................................................................909ConnectApi.GroupMember Class.................................................................................................................909ConnectApi.GroupMemberPage Class.........................................................................................................910ConnectApi.GroupMembershipRequest Class.............................................................................................910ConnectApi.GroupMembershipRequests Class............................................................................................911ConnectApi.HashtagSegment Class.............................................................................................................911ConnectApi.Icon Class..................................................................................................................................912ConnectApi.LabeledRecordField Class.........................................................................................................912ConnectApi.LinkAttachment Class..............................................................................................................912ConnectApi.LinkSegment Class...................................................................................................................913ConnectApi.MentionCompletion Class........................................................................................................913ConnectApi.MentionCompletionPage Class................................................................................................913ConnectApi.MentionSegment Class.............................................................................................................914ConnectApi.MentionValidation Class..........................................................................................................914ConnectApi.MentionValidations Class.........................................................................................................915ConnectApi.MessageBody Class...................................................................................................................915ConnectApi.MessageSegment Class.............................................................................................................915ConnectApi.ModerationCapability Class.....................................................................................................916ConnectApi.ModerationFlags Class.............................................................................................................916ConnectApi.MoreChangesSegment Class....................................................................................................917ConnectApi.Motif Class...............................................................................................................................917ConnectApi.OrganizationSettings Class.......................................................................................................918ConnectApi.PercentRecordField Class.........................................................................................................918ConnectApi.PhoneNumber Class.................................................................................................................918ConnectApi.Photo Class...............................................................................................................................919ConnectApi.PicklistRecordField Class.........................................................................................................919ConnectApi.PollCapability Class..................................................................................................................919ConnectApi.QuestionAndAnswersCapability...............................................................................................920

    xii

    Table of Contents

  • ConnectApi.RecordField Class.....................................................................................................................920ConnectApi.RecordSnapshotAttachment Class............................................................................................920ConnectApi.RecordSummary Class..............................................................................................................920ConnectApi.RecordSummaryList Class........................................................................................................920ConnectApi.RecordView Class.....................................................................................................................920ConnectApi.RecordViewSection Class.........................................................................................................921ConnectApi.Reference Class.........................................................................................................................921ConnectApi.ReferenceRecordField Class.....................................................................................................921ConnectApi.ReferenceWithDateRecordField Class.....................................................................................922ConnectApi.ResourceLinkSegment Class.....................................................................................................922ConnectApi.Subscription Class.....................................................................................................................922ConnectApi.TextSegment Class...................................................................................................................922ConnectApi.TimeZone Class........................................................................................................................922ConnectApi.Topic Class...............................................................................................................................923ConnectApi.TopicEndorsement Class..........................................................................................................923ConnectApi.TopicEndorsementCollection Class.........................................................................................923ConnectApi.TopicPage Class........................................................................................................................924ConnectApi.TopicsCapability Class..............................................................................................................924ConnectApi.TopicSuggestion Class..............................................................................................................924ConnectApi.TopicSuggestionPage Class......................................................................................................924ConnectApi.TrackedChangeAttachment Class............................................................................................924ConnectApi.TrackedChangeBundleCapability.............................................................................................924ConnectApi.TrackedChangeItem Class........................................................................................................925ConnectApi.UnauthenticatedUser Class.......................................................................................................925ConnectApi.UnreadConversationCount Class..............................................................................................925ConnectApi.User Class.................................................................................................................................925ConnectApi.UserCapabilities Class...............................................................................................................926ConnectApi.UserChatterSettings Class........................................................................................................927ConnectApi.UserDetail Class........................................................................................................................927ConnectApi.UserGroupPage Class...............................................................................................................928ConnectApi.UserPage Class..........................................................................................................................928ConnectApi.UserProfile Class.......................................................................................................................929ConnectApi.UserProfileTab Class................................................................................................................929ConnectApi.UserSettings Class.....................................................................................................................929ConnectApi.UserSummary Class..................................................................................................................930ConnectApi.Zone Class................................................................................................................................930ConnectApi.ZonePage Class.........................................................................................................................931ConnectApi.ZoneSearchPage Class..............................................................................................................931ConnectApi.ZoneSearchResult Class............................................................................................................932

    ConnectApi Enums...................................................................................................................................................932ConnectApi Exceptions............................................................................................................................................940

    Database Namespace.............................................................................................................................................................940Batchable Interface....................................................................................................................................................941

    Batchable Methods........................................................................................................................................941

    xiii

    Table of Contents

  • BatchableContext Interface.......................................................................................................................................943BatchableContext Methods...........................................................................................................................943

    DeletedRecord Class.................................................................................................................................................944DeletedRecord Methods................................................................................................................................944

    DeleteResult Class.....................................................................................................................................................945DeleteResult Methods...................................................................................................................................946

    DMLOptions Class...................................................................................................................................................947DmlOptions Properties.................................................................................................................................947

    DmlOptions.AssignmentRuleHeader Class..............................................................................................................949DmlOptions.AssignmentRuleHeader Properties..........................................................................................950

    DmlOptions.EmailHeader Class..............................................................................................................................951DmlOptions.EmailHeader Properties...........................................................................................................951

    EmptyRecycleBinResult Class..................................................................................................................................953EmptyRecycleBinResult Methods.................................................................................................................953

    Error Class.................................................................................................................................................................954Error Methods...............................................................................................................................................954

    GetDeletedResult Class............................................................................................................................................955GetDeletedResult Methods...........................................................................................................................955

    GetUpdatedResult Class...........................................................................................................................................956GetUpdatedResult Methods..........................................................................................................................956

    LeadConvert Class....................................................................................................................................................957LeadConvert Constructors......