Version 10.0: Salesforce Summer '07 Apex Web Services API Developer's Guide © Copyright 2000-2007 salesforce.com, inc. All rights reserved. Salesforce.com and the “no software” logo are registered trademarks, and AppExchange,“Success On Demand,” and “The Business Web” are trademarks of salesforce.com, inc. All other trademarks mentioned in this document are the properties of their respective owners. Table of Contents Table of Contents Getting Started.................................................................................................................................................9 Chapter 1: Introducing the Apex API..........................................................................................9 Customize, Integrate, and Extend Your Salesforce Solutions........................................................................................9 Supported Salesforce Editions.....................................................................................................................................10 Standards Compliance.................................................................................................................................................10 Development Platforms...............................................................................................................................................10 API Support Policy.....................................................................................................................................................10 What’s New in Version 10.0........................................................................................................................................11 Related Resources .......................................................................................................................................................11 Chapter 2: Quick Start..............................................................................................................12 Step 1: Obtain a Salesforce Developer Edition Account.............................................................................................13 Step 2: Generate or Obtain the Web Service WSDL.................................................................................................13 Step 3: Import the WSDL File Into Your Development Platform.............................................................................14 Step 4:Walk Through the Sample Code.....................................................................................................................15 Java Sample Code............................................................................................................................................15 C# Sample Code .............................................................................................................................................21 Chapter 3:Standard and Custom Object Basics ..........................................................................26 Primitive Data Types...................................................................................................................................................27 Field Types..................................................................................................................................................................28 Core Data Types Used in API Calls............................................................................................................................32 System Fields...............................................................................................................................................................38 Required Fields............................................................................................................................................................40 Frequently-Occurring Fields.......................................................................................................................................40 API Field Properties....................................................................................................................................................41 Relationships Among Objects.....................................................................................................................................42 Relabeling Fields and Tabs and the API.....................................................................................................................42 AppExchange Object Prefixes and the API................................................................................................................42 Custom Objects...........................................................................................................................................................43 Chapter 4:API Call Basics ........................................................................................................46 Characteristics of API Calls........................................................................................................................................47 Factors that Affect Data Access...................................................................................................................................47 Chapter 5:Error Handling.........................................................................................................50 Error Handling for Session Expiration .......................................................................................................................51 More About Error Handling.......................................................................................................................................51 Chapter 6:Security and the API.................................................................................................52 User Authentication....................................................................................................................................................53 User Profile Configuration..........................................................................................................................................53 i Table of Contents Sharing........................................................................................................................................................................53 Implicit Restrictions for Objects and Fields................................................................................................................53 Chapter 7:Using the Partner WSDL..........................................................................................54 Obtaining the Partner WSDL File.............................................................................................................................55 Calls and the Partner WSDL .....................................................................................................................................55 Objects, Fields, and Field Data and the Partner WSDL.............................................................................................55 Queries and the Partner WSDL..................................................................................................................................56 Namespaces in the Partner WSDL.............................................................................................................................56 User Interface Themes.................................................................................................................................................56 Examples.....................................................................................................................................................................56 Sample query Calls..........................................................................................................................................57 Sample search Call...........................................................................................................................................58 Sample create Call...........................................................................................................................................60 Sample update Call..........................................................................................................................................62 Reference.........................................................................................................................................................64 Chapter 8:Data Model..............................................................................................................64 Sales Objects................................................................................................................................................................65 Task and Event Objects...............................................................................................................................................66 Support Objects...........................................................................................................................................................66 Document, Note, and Attachment Objects.................................................................................................................67 User and Profile Objects..............................................................................................................................................67 Record Type Objects...................................................................................................................................................68 Product and Schedule Objects.....................................................................................................................................68 Sharing and Team Selling Objects...............................................................................................................................69 Customizable Forecasting Objects...............................................................................................................................70 Territory Management................................................................................................................................................71 Process Objects............................................................................................................................................................72 Chapter 9:Standard Objects......................................................................................................73 Account.......................................................................................................................................................................77 AccountContactRole...................................................................................................................................................84 AccountOwnerSharingRule........................................................................................................................................85 AccountPartner............................................................................................................................................................87 AccountShare..............................................................................................................................................................88 AccountTeamMember.................................................................................................................................................90 AccountTerritoryAssignmentRule...............................................................................................................................91 AccountTerritoryAssignmentRuleItem.......................................................................................................................93 AccountTerritorySharingRule.....................................................................................................................................94 ActivityHistory............................................................................................................................................................95 AdditionalNumber......................................................................................................................................................98 Approval......................................................................................................................................................................99 Asset..........................................................................................................................................................................101 AssignmentRule........................................................................................................................................................103 ii Table of Contents Attachment................................................................................................................................................................104 BrandTemplate..........................................................................................................................................................106 BusinessHours...........................................................................................................................................................107 BusinessProcess.........................................................................................................................................................110 CallCenter.................................................................................................................................................................111 Campaign..................................................................................................................................................................112 CampaignMember.....................................................................................................................................................115 CampaignMemberStatus...........................................................................................................................................117 Case...........................................................................................................................................................................118 CaseComment...........................................................................................................................................................122 CaseContactRole ......................................................................................................................................................123 CaseHistory...............................................................................................................................................................124 CaseOwnerSharingRule............................................................................................................................................125 CaseShare..................................................................................................................................................................126 CaseSolution..............................................................................................................................................................127 CaseStatus.................................................................................................................................................................128 CategoryData............................................................................................................................................................129 CategoryNode...........................................................................................................................................................130 CategoryNodeLocalization........................................................................................................................................131 Contact......................................................................................................................................................................132 ContactShare.............................................................................................................................................................136 ContactOwnerSharingRule.......................................................................................................................................138 Contract.....................................................................................................................................................................138 ContractContactRole ...............................................................................................................................................142 ContractHistory........................................................................................................................................................143 ContractStatus...........................................................................................................................................................144 CurrencyType............................................................................................................................................................145 DatedConversionRate...............................................................................................................................................146 Division.....................................................................................................................................................................147 Document..................................................................................................................................................................148 DocumentAttachmentMap.......................................................................................................................................151 EmailMessage............................................................................................................................................................151 EmailStatus...............................................................................................................................................................153 EmailTemplate..........................................................................................................................................................154 EntityHistory............................................................................................................................................................156 Event.........................................................................................................................................................................157 EventAttendee...........................................................................................................................................................162 FiscalYearSettings......................................................................................................................................................164 Folder.........................................................................................................................................................................165 Group........................................................................................................................................................................166 GroupMember...........................................................................................................................................................168 Lead...........................................................................................................................................................................168 LeadHistory..............................................................................................................................................................175 LeadOwnerSharingRule............................................................................................................................................176 LeadShare..................................................................................................................................................................177 iii Table of Contents LeadStatus.................................................................................................................................................................178 LineitemOverride......................................................................................................................................................179 MailMergeTemplate..................................................................................................................................................180 Name.........................................................................................................................................................................182 Note...........................................................................................................................................................................183 NoteAndAttachment.................................................................................................................................................184 OpenActivity.............................................................................................................................................................185 Opportunity...............................................................................................................................................................187 OpportunityCompetitor............................................................................................................................................192 OpportunityContactRole...........................................................................................................................................193 OpportunityHistory...................................................................................................................................................194 OpportunityLineItem................................................................................................................................................195 OpportunityLineItemSchedule.................................................................................................................................198 OpportunityOverride................................................................................................................................................201 OpportunityOwnerSharingRule................................................................................................................................202 OpportunityPartner...................................................................................................................................................203 OpportunityShare......................................................................................................................................................204 OpportunityStage......................................................................................................................................................205 OpportunityTeamMember........................................................................................................................................207 Organization..............................................................................................................................................................208 Partner.......................................................................................................................................................................215 PartnerRole ...............................................................................................................................................................217 Period........................................................................................................................................................................218 Pricebook2.................................................................................................................................................................219 PricebookEntry .........................................................................................................................................................221 ProcessInstance..........................................................................................................................................................223 ProcessInstanceHistory..............................................................................................................................................224 ProcessInstanceStep...................................................................................................................................................225 ProcessInstanceWorkitem..........................................................................................................................................226 Product2 ...................................................................................................................................................................227 Profile........................................................................................................................................................................230 QuantityForecast.......................................................................................................................................................232 QuantityForecastHistory...........................................................................................................................................237 QueueSobject............................................................................................................................................................238 RecordType...............................................................................................................................................................239 RevenueForecast .......................................................................................................................................................240 RevenueForecastHistory ...........................................................................................................................................245 Scontrol.....................................................................................................................................................................246 ScontrolLocalization..................................................................................................................................................248 SelfServiceUser .........................................................................................................................................................249 Solution.....................................................................................................................................................................251 SolutionHistory ........................................................................................................................................................254 SolutionStatus...........................................................................................................................................................254 Task...........................................................................................................................................................................255 TaskPriority...............................................................................................................................................................258 iv Table of Contents TaskStatus..................................................................................................................................................................259 Territory.....................................................................................................................................................................260 User...........................................................................................................................................................................261 UserAccountTeamMember.......................................................................................................................................269 UserLicense...............................................................................................................................................................270 UserPreference...........................................................................................................................................................271 UserRole....................................................................................................................................................................272 UserTeamMember.....................................................................................................................................................274 UserTerritory.............................................................................................................................................................275 WebLink....................................................................................................................................................................276 WebLinkLocalization................................................................................................................................................279 Chapter 10:Core Calls.............................................................................................................281 convertLead...............................................................................................................................................................282 LeadConvertResult........................................................................................................................................286 create..........................................................................................................................................................................286 SaveResult......................................................................................................................................................290 delete.........................................................................................................................................................................290 DeleteResult..................................................................................................................................................292 emptyRecycleBin.......................................................................................................................................................293 EmptyRecycleBinResult................................................................................................................................294 getDeleted.................................................................................................................................................................295 GetDeletedResult..........................................................................................................................................298 getUpdated................................................................................................................................................................298 GetUpdatedResult.........................................................................................................................................301 login...........................................................................................................................................................................301 LoginResult...................................................................................................................................................303 merge.........................................................................................................................................................................304 mergeResult...................................................................................................................................................306 process.......................................................................................................................................................................306 ProcessResult.................................................................................................................................................309 query..........................................................................................................................................................................309 QueryResult...................................................................................................................................................312 QueryLocator................................................................................................................................................312 Sforce Object Query Language (SOQL).......................................................................................................313 queryAll.....................................................................................................................................................................335 queryMore.................................................................................................................................................................337 QueryResult...................................................................................................................................................339 QueryLocator................................................................................................................................................340 retrieve.......................................................................................................................................................................340 search.........................................................................................................................................................................342 SearchResult..................................................................................................................................................345 Sforce Object Search Language (SOSL).......................................................................................................345 undelete.....................................................................................................................................................................359 UndeleteResult...............................................................................................................................................361 v Table of Contents update........................................................................................................................................................................361 SaveResult......................................................................................................................................................364 upsert.........................................................................................................................................................................365 UpsertResult..................................................................................................................................................368 Chapter 11:Describe Calls.......................................................................................................369 describeGlobal...........................................................................................................................................................369 DescribeGlobalResult....................................................................................................................................370 describeLayout...........................................................................................................................................................371 DescribeLayoutResult....................................................................................................................................374 describeSObject.........................................................................................................................................................378 DescribeSObjectResult..................................................................................................................................380 describeSObjects........................................................................................................................................................380 DescribeSObjectResult..................................................................................................................................383 describeSoftphoneLayout..........................................................................................................................................391 describeTabs..............................................................................................................................................................392 DescribeTabSetResult....................................................................................................................................393 Chapter 12: Utility Calls..........................................................................................................395 getServerTimestamp..................................................................................................................................................395 GetServerTimestampResult..........................................................................................................................396 getUserInfo................................................................................................................................................................396 GetUserInfoResult.........................................................................................................................................398 resetPassword.............................................................................................................................................................399 sendEmail..................................................................................................................................................................400 SendEmailResult...........................................................................................................................................404 setPassword................................................................................................................................................................405 Chapter 13:SOAP Headers......................................................................................................407 AssignmentRuleHeader ............................................................................................................................................407 CallOptions...............................................................................................................................................................408 EmailHeader.............................................................................................................................................................409 MruHeader................................................................................................................................................................410 LoginScopeHeader....................................................................................................................................................410 QueryOptions............................................................................................................................................................411 SessionHeader...........................................................................................................................................................411 UserTerritoryDeleteHeader ......................................................................................................................................412 Using the API with Salesforce Features.......................................................................................................413 Chapter 14: Implementation Considerations............................................................................413 Login Server URL.....................................................................................................................................................414 Start By Logging In to the Login Server..................................................................................................................414 Typical API Call Sequence........................................................................................................................................414 Salesforce Sandbox....................................................................................................................................................414 Multiple Instances of Salesforce.com Database Servers............................................................................................415 Content Type Requirement.......................................................................................................................................415 vi Table of Contents Monitoring API Traffic.............................................................................................................................................415 API Usage Metering..................................................................................................................................................415 Compression..............................................................................................................................................................416 HTTP Persistent Connections..................................................................................................................................417 HTTP Chunking......................................................................................................................................................417 Internationalization and Character Sets....................................................................................................................417 XML Compliance.....................................................................................................................................................417 .Net, Non-String Fields, and the Enterprise WSDL................................................................................................418 Chapter 15:Outbound Messaging............................................................................................419 Setting Up Outbound Messaging..............................................................................................................................421 Setting Up User Profiles................................................................................................................................421 Defining Outbound Messaging.....................................................................................................................422 Downloading the Salesforce Client Certificate..............................................................................................422 Viewing Outbound Messages........................................................................................................................423 Tracking Outbound Message Status..............................................................................................................423 Important Security Considerations............................................................................................................................423 Understanding the Outbound Messaging WSDL....................................................................................................423 Building a Listener....................................................................................................................................................425 Chapter 16:Data Loading and Integration................................................................................427 Client Application Design.........................................................................................................................................428 Salesforce Settings.....................................................................................................................................................428 Best Practices with Any Data Loader .......................................................................................................................429 Integration and Single Sign-On................................................................................................................................430 Chapter 17:Data Replication...................................................................................................431 API Calls for Data Replication.................................................................................................................................432 Scope of Data Replication.........................................................................................................................................432 Data Replication Steps..............................................................................................................................................432 Object-Specific Requirements for Data Replication.................................................................................................432 Polling for Changes...................................................................................................................................................433 Checking for Structural Changes in the Object........................................................................................................434 Chapter 18:Feature-Specific Considerations............................................................................435 Archived Activities....................................................................................................................................................436 Person Account Record Types...................................................................................................................................436 Opportunity Forecast Override Business Rules.........................................................................................................437 OpportunityOverride Lifecycle.....................................................................................................................438 LineitemOverride Object Lifecycle ..............................................................................................................439 Call Centers and the API..........................................................................................................................................440 Implementing Salesforce Integrations on Apex.........................................................................................................442 Chapter 19:Metadata Calls and Objects (Developer Preview Release).......................................443 Metadata Field Types................................................................................................................................................444 checkStatus................................................................................................................................................................445 create (Asynchronous)...............................................................................................................................................446 vii Table of Contents AsyncResult...................................................................................................................................................447 update (Asynchronous)..............................................................................................................................................448 AsyncResult...................................................................................................................................................450 delete (Asynchronous)...............................................................................................................................................451 AsyncResult...................................................................................................................................................452 CustomObject...........................................................................................................................................................453 CustomField..............................................................................................................................................................455 Metadata....................................................................................................................................................................457 UpdateMetadata........................................................................................................................................................458 Index..............................................................................................................................................................459 viii
Description: