text
stringlengths
24
5.1k
apex reference guide version 58.0, summer ’23 @salesforcedocs last updated: june 15, 2023© copyright 2000–2023 salesforce, inc. all rights reserved. salesforce is a registered trademark of salesforce, inc., as are other names and marks. other marks appearing herein may be trademarks of their respective owners.contents apex reference guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 release notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 apex dml operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 apex dml statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 apexpages namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 action class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 component class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 ideastandardcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 ideastandardsetcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 knowledgearticleversionstandardcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 message class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 standardcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 standardsetcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 applauncher namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 appmenu class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 communitylogocontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 employeeloginlinkcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 sociallogincontroller class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 approval namespace . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 lockresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 processrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 processresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 processsubmitrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 processworkitemrequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 unlockresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 auth namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 authconfiguration class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 authprovidercallbackstate class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 authproviderplugin interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 authproviderpluginclass class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 authprovidertokenresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 authtoken class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 communitiesutil class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 configurableselfreghandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 confirmuserregistrationhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 connectedappplugin class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 headlessselfregistrationhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 invocationcontext enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 jws class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
115contents jwt class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 jwtbearertokenexchange class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 lightninglogineligibility enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 logindiscoveryhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 logindiscoverymethod enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 mydomainlogindiscoveryhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 oauthrefreshresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 registrationhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 samljithandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 sessionmanagement class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 sessionlevel enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 userdata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 verificationmethod enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 verificationpolicy enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 verificationresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 auth exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 cache namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 cachebuilder interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 org class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 orgpartition class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 partition
class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 session class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 sessionpartition class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 cache exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 visibility enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 canvas namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 applicationcontext interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 canvaslifecyclehandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 contexttypeenum enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 environmentcontext interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 rendercontext interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 test class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 canvas exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 chatteranswers namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 accountcreator interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 commercepayments namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 abstractresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 addressrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 auditparamsrequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 abstracttransactionresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 authapipaymentmethodrequest class. . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 authorizationreversalrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 authorizationreversalresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 authorizationrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283contents authorizationresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 baseapipaymentmethodrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 basenotification class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 basepaymentmethodrequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 baserequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 capturenotification class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 capturerequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 captureresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 cardcategory enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 cardpaymentmethodrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 custommetadatatypeinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 gatewayerrorresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 gatewaynotificationresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 gatewayresponse interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 notificationclient class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 notificationsaveresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 notificationstatus enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 paymentgatewayadapter interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
333 paymentgatewayasyncadapter interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 paymentgatewaycontext class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 paymentgatewaynotificationcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 paymentmethodtokenizationrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 paymentmethodtokenizationresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345 paymentgatewaynotificationrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 paymentshttp class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 refundrequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 referencedrefundnotification class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 referencedrefundrequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 referencedrefundresponse class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 requesttype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 saleapipaymentmethodrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 salerequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 saleresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 salesforceresultcode enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 salesforceresultcodeinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 connectapi namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 actionlinks class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 announcements class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 botversionactivation class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 cdpcalculatedinsight class. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 cdpidentityresolution class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 cdpquery class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410 cdpsegment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 chatter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432contents chatterfavorites class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437 chatterfeeds class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 chattergroups class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 862 chattermessages class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907 chatterusers class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931 clm class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 966 commercebuyerexperience class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968 commercecart class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022 commercecatalog class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058 commercepromotions class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1075 commercesearch class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1078 commercesearchsettings class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1083 commercestorepricing class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1086 commercewishlist class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1090 communities class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1108 communitymoderation class . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1111 contenthub class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140 conversationapplicationdefinition class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214 datacloud class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1215 emailmergefieldservice class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1220 employeeprofiles class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1221 externalemailservices class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1230 externalmanagedaccount class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231 fieldservice class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1234 fulfillmentorder class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237 knowledge class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1242 lightningscheduler class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1247 managedcontent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1252 managedcontentdelivery class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1273 managedtopics class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1290 marketingintegration class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1305 mentions class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1307 missions class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313 namedcredentials class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1318 navigationmenu class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1329 nextbestaction class . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1333 omnichannelinventoryservice class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339 orchestration class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1346 orderpaymentsummary class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347 ordersummary class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1349 ordersummarycreation class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1361 organization class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1362 pardotbusinessunitcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1362 payments class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1364contents personalization class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1369 pick ticket class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1382 questionandanswers class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1383 recommendations class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1386 records class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448 repricing class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1450 returnorder class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1452 routing class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1454 salesforceinbox class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1459 sites class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1460 smartdatadiscovery class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461 socialengagement class . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461 surveys class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1472 taxplatform class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1473 topics class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474 userprofiles class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1511 zones class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1521 connectapi input classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1531 connectapi output classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1664 connectapi enums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1999 connectapi exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2030 connectapi utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2030 connectapi release notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2031 database namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2031 batchable interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2032 batchablecontext interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2034 deletedrecord class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2035 deleteresult class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2036 dmloptions class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2038 dmloptions.assignmentruleheader class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2041 dmloptions.duplicateruleheader class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2042
dmloptions.emailheader class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2044 duplicateerror class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2047 emptyrecyclebinresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2049 error class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2050 getdeletedresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2052 getupdatedresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2053 leadconvert class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2054 leadconvertresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2064 mergeresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2067 querylocator class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2069 querylocatoriterator class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2070 saveresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2072 undeleteresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2074contents upsertresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2075 datacloud namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2077 additionalinformationmap class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2078 duplicateresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2079 fielddiff class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2084 findduplicates class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2085 findduplicatesbyids class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . 2086 findduplicatesresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2088 matchrecord class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2091 matchresult class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2092 datasource namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2095 asyncdeletecallback class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2097 asyncsavecallback class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2098 authenticationcapability enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2099 authenticationprotocol enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2099 capability enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2100 column class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2101 columnselection class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2117 connection class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2118 connectionparams class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2124 datasourceutil class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2127 datatype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2128 deletecontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2129 deleteresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2130 filter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2133 filtertype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2135 identitytype enum . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2136 order class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2137 orderdirection enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2139 provider class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2139 queryaggregation enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2141 querycontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2141 queryutils class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2143 readcontext class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2146 searchcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2147 searchutils class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2149 table class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2150 tableresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2154 tableselection class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2160 upsertcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2161 upsertresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2162 datasource exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2165 dataweave namespace (beta) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2166 result class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2166contents script class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2168 dom namespace . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2171 document class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2171 xmlnode class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2174 eventbus namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2184 changeeventheader class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2185 eventpublishfailurecallback interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2190 eventpublishsuccesscallback interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2191 failureresult interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2192 successresult interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2193 testbroker class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2194 triggercontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2196 externalservice namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2198 flow namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2199 interview class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2199 functions namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2203 function class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2204 functioncallback interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2208 functionerrortype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2210 functioninvocation interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2210 functioninvocationerror interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2213 functioninvocationstatus enum . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . 2214 functioninvokemock interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2215 mockfunctioninvocationfactory class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2218 invocable namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2219 action class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2220 action.error class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2225 action.result class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2226 kbmanagement namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2228 publishingservice class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2229 lxscheduler namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2240 getappointmentcandidatesinput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2241 getappointmentcandidatesinputbuilder class . . . . . . . . . . . . . . . . . . . . . . . . . . . 2243 getappointmentslotsinput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2250 getappointmentslotsinputbuilder class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2253 schedulerresources class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2260 skillrequirement class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2265 skillrequirementbuilder class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2265 worktype class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2266 worktypebuilder class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2267 serviceresourceschedulehandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2271 serviceappointmentrequestinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2274 serviceresourceinfo class . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . 2278 serviceresourceschedule class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2281contents unavailabletimeslot class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2282 messaging namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2284 attachmentretrievaloption enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2285 email class (base email methods) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2286 emailfileattachment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2289 inboundemail class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2291 inboundemail.authenticationresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2298 inboundemail.authenticationresultfield class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2299 inboundemail.binaryattachment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2301 inboundemail.textattachment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2303 inboundemailresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2305 inboundenvelope class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2306 massemailmessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2307 inboundemail.header class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2310 pushnotification class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2311 pushnotificationpayload class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2314 customnotification class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2316 renderemailtemplatebodyresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2323 renderemailtemplateerror class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2325 sendemailerror class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2326 sendemailresult class
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2328 singleemailmessage methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2329 metadata namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2341 analyticscloudcomponentlayoutitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2344 consolecomponent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2348 container class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2350 customconsolecomponents class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2353 custommetadata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2354 custommetadatavalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2357 deploycallback interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2359 deploycallbackcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2360 deploycontainer class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2362 deploydetails class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2364 deploymessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2366 deployproblemtype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2371 deployresult class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2371 deploystatus enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2379 feeditemtypeenum enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2380 feedlayout class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2381 feedlayoutcomponent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2385 feedlayoutcomponenttype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2387 feedlayoutfilter
class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2387 feedlayoutfilterposition enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2389 feedlayoutfiltertype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2390contents layout class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2390 layoutcolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2397 layoutheader enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2399 layoutitem class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2399 layoutsection class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2404 layoutsectionstyle enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2407 metadata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2407 metadatatype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2409 metadatavalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2409 minilayout class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2410 operations class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2411 platformactionlist class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2415 platformactionlistcontextenum enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2417 platformactionlistitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2418 platformactiontypeenum enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2420 primarytabcomponents class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2420 quickactionlist class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2422 quickactionlistitem class . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2423 relatedcontent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2424 relatedcontentitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2425 relatedlist class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2427 relatedlistitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2428 reportchartcomponentlayoutitem class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2431 reportchartcomponentsize enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2434 sidebarcomponent class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2435 sortorder enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2439 statuscode enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2439 subtabcomponents class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2440 summarylayoutstyleenum enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2441 summarylayout class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2442 summarylayoutitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2445 uibehavior enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2447 pref_center namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2447 loadformdata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2448 loadparameters class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2454 preferencecenterapexhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2455 submitformdata class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2457 submitparameters class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . 2460 tokentype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2461 tokenutility class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2462 validationresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2464 process namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2465 plugin interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2465 plugindescriberesult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2467contents plugindescriberesult.inputparameter class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2470 plugindescriberesult.outputparameter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2473 pluginrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2476 pluginresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2476 quickaction namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2477 describeavailablequickactionresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2478 describelayoutcomponent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2480 describelayoutitem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2481 describelayoutrow class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2483 describelayoutsection class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2484 describequickactiondefaultvalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2488 describequickactionresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2489 quickactiondefaults class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2505 quickactiondefaultshandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2507 quickactionrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . 2512 quickactionresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2515 sendemailquickactiondefaults class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2517 reports namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2519 aggregatecolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2523 bucketfield class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2524 bucketfieldvalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2531 buckettype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2535 columndatatype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2535 columnsortorder enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2536 crossfilter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2537 csfgrouptype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2542 dategranularity enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2542 detailcolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2543 dimension class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2544 evaluatedcondition class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2545 evaluatedconditionoperator enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2548 filteroperator class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2549 filtervalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2550 formulatype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2551 groupingcolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . 2551 groupinginfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2553 groupingvalue class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2554 notificationaction interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2556 notificationactioncontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2558 reportcsf class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2559 reportcurrency class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2568 reportdatacell class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2569 reportdescriberesult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2570 reportdetailrow class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2571contents reportdivisioninfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2572 reportextendedmetadata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2573 reportfact class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2574 reportfactwithdetails class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2575 reportfactwithsummaries class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2576 reportfilter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2578 reportformat enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2582 reportfiltertype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2583 reportinstance class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2583 reportmanager class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2586 reportmetadata class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . 2591 reportresults class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2611 reportscopeinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2613 reportscopevalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2614 reporttype class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2615 reporttypecolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2616 reporttypecolumncategory class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2618 reporttypemetadata class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2620 sortcolumn class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2622 standarddatefilter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2623 standarddatefilterduration class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2626 standarddatefilterdurationgroup class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2628 standardfilter class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2629 standardfilterinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2631 standardfilterinfopicklist class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2632 standardfiltertype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2634 summaryvalue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2634 thresholdinformation class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2635 toprows class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2636 reports exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2639 richmessaging namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2640 authrequesthandler interface . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . 2640 authrequestresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2643 authrequestresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2645 authrequestresultstatus enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2647 messagedefinitioninputparameter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2647 timeslotoption class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2651 schema namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2653 childrelationship class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2654 datacategory class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2657 datacategorygroupsobjecttypepair class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2658 describecolorresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2660 describedatacategorygroupresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2662 describedatacategorygroupstructureresult class . . . . . . . . . . . . . . . . . . . . . . . . . 2664contents describefieldresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2667 describeiconresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2684 describesobjectresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2686 describetabresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2699 describetabsetresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2702 displaytype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2705 fielddescribeoptions enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2707 fieldset class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2707 fieldsetmember class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . 2711 picklistentry class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2713 recordtypeinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2715 soaptype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2718 sobjectdescribeoptions enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2718 sobjectfield class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2719 sobjecttype class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2720 search namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2724 knowledgesuggestionfilter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2725 questionsuggestionfilter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2729 searchresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2733 searchresults class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2735 suggestionoption class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2736 suggestionresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2737 suggestionresults class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2738 sfc namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2739 contentdownloadcontext enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2739 contentdownloadhandler class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2740 contentdownloadhandlerfactory interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2741 sfdc_checkout namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2743 asynccartprocessor interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2743 b2
bcheckoutcontroller class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2744 integrationinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2745 integrationstatus class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2747 integrationstatus.status enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2748 sfdc_surveys namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2748 surveyinvitationlinkshortener interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2748 example implementation to associate surveysubjects with surveyinvitation and surveyresponses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2750 site namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2751 urlrewriter interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2752 site exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2753 support namespace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2754 emailtemplateselector interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2754 milestonetriggertimecalculator interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2756 system namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2758contents accesslevel class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2765 accesstype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2766 address class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2766 answers class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2772 apexpages class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2774 approval class . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2776 assert class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2788 asyncinfo class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2801 asyncoptions class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2802 blob class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2803 boolean class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2806 businesshours class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2807 callable interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2811 cases class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2813 comparable interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2817 continuation class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2820 cookie class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2824 crypto class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2830 custom metadata type methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2846 custom settings methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2849 database class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2860 date class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2951 datetime class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2961 decimal class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2985 domain class. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2998 domaincreator class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3001 domainparser class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3005 domaintype enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3007 double class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3007 emailmessages class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3011 encodingutil class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3015 enum methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3018 eventbus class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3019 exception class and built-in exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3021 flexqueue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3026 featuremanagement class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3029 formula class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3035 formularecalcfielderror class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3036 formularecalcresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3037 http class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3038 httpcalloutmock interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3039 httprequest class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3040 httpresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3050 id class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . 3056contents ideas class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3063 installhandler interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3068 integer class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3071 json class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3073 jsongenerator class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3080 jsonparser class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3094 jsontoken enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3106 label class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3107 limits class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3110 list class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3123 location class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3138 logginglevel enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3141 long class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3142 map class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3144 matcher class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3156 math class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3168 messaging class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3194 multistaticresourcecalloutmock class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3202 network class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . 3205 orglimit class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3210 orglimits class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3213 pagereference class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3214 packaging class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3226 pattern class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3227 queueable interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3231 queueablecontext interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3233 quickaction class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3234 quiddity enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3238 remoteobjectcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3239 request class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3243 resetpasswordresult class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3245 restcontext class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3245 restrequest class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3247 restresponse class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3252 sandboxpostcopy interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3256 schedulable interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3259 schedulablecontext interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3259 schema class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3260 search class . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3265 security class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3271 selectoption class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3274 set class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3279 site class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3291 sobject class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3312contents sobjectaccessdecision class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3338 staticresourcecalloutmock class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3340 string class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3343 stubprovider interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3418 system class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3420 test class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3444 time class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3462 timezone class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3467 trigger class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3470 triggeroperation enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3473 type class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3473 uninstallhandler interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3481 url class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3483 userinfo class . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3493 usermanagement class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3502 version class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3521 webservicecallout class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3525 webservicemock interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3526 xmlstreamreader class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3528 xmlstreamwriter class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3542 territorymgmt namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3549 opportunityterritory2assignmentfilter global interface . . . . . . . . . . . . . . . . . . . . . . 3549 txnsecurity namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3553 event class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3553 eventcondition interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3557 asynccondition interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3559 policycondition interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3560 userprovisioning namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3562 connectortestutil class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3562 userprovisioninglog class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3564 userprovisioningplugin class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3566 visualeditor namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3570 datarow class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3571 designtimepagecontext class . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . 3574 dynamicpicklist class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3576 dynamicpicklistrows class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3579 wave namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3584 querybuilder class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3584 querynode class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3588 projectionnode class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3592 templates class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3595 templatessearchoptions class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3598 appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3600 shipping invoice example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3600contents reserved keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3612 documentation typographical conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3613 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3614apex reference guide apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the salesforce platform server, in conjunction with calls to the api. this reference guide includes built-in apex classes, interfaces, enums, and exceptions, grouped by namespace. it also includes apex dml statements to insert, update, merge, delete, and restore data in salesforce. for information on the apex development process, see apex developer guide. note: in api version 51.0 and earlier, apex reference information was included in the apex developer guide in the apex language reference section. in this section: apex release notes use the salesforce release notes to learn about the most recent updates and changes to apex. apex dml operations you can perform dml operations using the apex dml statements or the methods of the database class. for lead conversion, use the convertlead method of the database class. there is no dml counterpart for it. apexpages namespace the apexpages namespace provides classes used in visualforce controllers. applauncher namespace the applauncher namespace provides methods for managing the appearance of apps in the app launcher, including their visibility and sort order. approval namespace the approval namespace provides classes and methods for approval processes. auth namespace the auth namespace provides an interface and classes for single sign-on into salesforce and session security management. cache namespace the
cache namespace contains methods for managing the platform cache. canvas namespace the canvas namespace provides an interface and classes for canvas apps in salesforce. chatteranswers namespace the chatteranswers namespace provides an interface for creating account records. commercepayments namespace use the commercepayments namespace to provide a safe and customizable platform for managing customer payments and refunds. connectapi namespace the connectapi namespace (also called connect in apex) provides classes for accessing the same data available in connect rest api. use connect in apex to create custom experiences in salesforce. database namespace the database namespace provides classes used with dml operations. 1apex reference guide datacloud namespace the datacloud namespace provides classes and methods for retrieving information about duplicate rules. duplicate rules let you control whether and when users can save duplicate records within salesforce. datasource namespace the datasource namespace provides the classes for the apex connector framework. use the apex connector framework to develop a custom adapter for salesforce connect. then connect your salesforce organization to any data anywhere via the salesforce connect custom adapter. dataweave namespace (beta) the dataweave namespace provides classes and methods to support the invocation of dataweave scripts from apex. dom namespace the dom namespace provides classes and methods for parsing and creating xml content. eventbus namespace the eventbus namespace provides classes and methods for platform events and change data capture events. externalservice namespace the externalservice namespace provides dynamically generated apex service interfaces and apex classes for complex object data types. flow namespace the flow namespace provides a class for advanced visualforce controller access to flows. functions namespace the functions namespace provides classes and methods used to invoke and manage salesforce functions. invocable namespace the invocable namespace provides classes for calling invocable actions from apex. kbmanagement namespace the kbmanagement namespace provides a class for managing knowledge articles. lxscheduler namespace the lxscheduler namespace provides an interface and classes for integrating salesforce scheduler with external calendars. messaging namespace the messaging namespace provides classes and methods for salesforce outbound and inbound email functionality. metadata namespace the metadata namespace provides classes and methods for working with custom metadata in salesforce pref_center namespace the pref_center namespace provides an interface, classes, and methods to create and retrieve data in forms in preference manager. preference manager, previously called preference center, is a feature within the privacy center app. process namespace the process namespace provides an interface and classes for passing data between your organization and a flow. quickaction namespace the quickaction namespace provides classes and methods for quick actions. reports namespace the reports namespace provides classes for accessing the same data as is available in the salesforce reports and dashboards rest api. 2apex reference guide apex release notes richmessaging namespace provides objects and methods for handling rich messaging content. schema namespace the schema namespace provides classes and methods for schema metadata information. search namespace the search namespace provides classes for getting search results and suggestion results. sfc namespace the sfc namespace contains classes used in salesforce files. sfdc_checkout namespace the sfdc_checkout namespace provides an interface and classes for b2b commerce apps in salesforce. sfdc_surveys namespace the sfdc_surveys namespace provides an interface for shortening survey invitations. site namespace the site namespace provides an interface for rewriting sites urls. support namespace the support namespace provides an interface used for case feed. system namespace the system namespace provides classes and methods for core apex functionality. territorymgmt namespace the territorymgmt namespace provides an interface used for territory management. txnsecurity namespace the txnsecurity namespace provides an interface used for transaction security. userprovisioning namespace the userprovisioning namespace provides methods for monitoring outbound user provisioning requests. visualeditor namespace the visualeditor namespace provides classes and methods for interacting with the lightning app builder. the classes and methods in this namespace operate on lightning components, which include lightning web components and aura components. wave namespace the classes in the wave namespace are part of the crm analytics analytics sdk, designed to facilitate querying crm analytics data from apex code. appendices apex release notes use the salesforce release notes to learn about the most recent updates and changes to apex. for apex updates and changes that impact the salesforce platform, see the apex release
notes. for new and changed apex classes, methods, exceptions and interfaces, see apex: new and changed items in the salesforce release notes. 3apex reference guide apex dml operations apex dml operations you can perform dml operations using the apex dml statements or the methods of the database class. for lead conversion, use the convertlead method of the database class. there is no dml counterpart for it. see also: apex developer guide: working with data in apex database class apex dml statements use data manipulation language (dml) statements to insert, update, merge, delete, and restore data in salesforce. the following apex dml statements are available: insert statement the insert dml operation adds one or more sobjects, such as individual accounts or contacts, to your organization’s data.insert is analogous to the insert statement in sql. syntax insert sobject insert sobject[] example the following example inserts an account named 'acme': account newacct = new account(name = 'acme'); try { insert newacct; } catch (dmlexception e) { // process exception here } note: for more information on processing dmlexceptions, see bulk dml exception handling. update statement the update dml operation modifies one or more existing sobject records, such as individual accounts or contacts, in your organization’s data. update is analogous to the update statement in sql. syntax update sobject update sobject[] 4apex reference guide apex dml statements example the following example updates the billingcity field on a single account named 'acme': account a = new account(name='acme2'); insert(a); account myacct = [select id, name, billingcity from account where id = :a.id]; myacct.billingcity = 'san francisco'; try { update myacct; } catch (dmlexception e) { // process exception here } note: for more information on processing dmlexceptions, see bulk dml exception handling. upsert statement the upsert dml operation creates new records and updates sobject records within a single statement,using a specified field to determine the presence of existing objects, or the id field if no field is specified. syntax upsert sobject [opt_field] upsert sobject[] [opt_field] the upsert statement matches the sobjects with existing records by comparing values of one field. if you don’t specify a field when calling this statement, the upsert statement uses the sobject’s id to match the sobject with existing records in salesforce. alternatively, you can specify a field to use for matching. for custom objects, specify a custom field marked as external id. for standard objects, you can specify any field that has the idlookup attribute set to true. for example, the email field of contact or user has the idlookup attribute set. to check a field’s attribute, see the object reference for salesforce. also, you can use foreign keys to upsert sobject records if they have been set as reference fields. for more information, see field types in the object reference for salesforce. the optional field parameter, opt_field, is a field token (of type schema.sobjectfield). for example, to specify the myexternalid custom field, the statement is: upsert sobjectlist account.fields.myexternalid__c; if the field used for matching doesn’t have the unique attribute set, the context user must have the “view all” object-level permission for the target object or the “view all data” permission so that upsert doesn’t accidentally insert a duplicate record. note: custom field matching is case-insensitive only if the custom field has the unique and treat "abc" and "abc" as duplicate values (case insensitive) attributes selected as part of the field definition. if so, “abc123” is matched with “abc123.” for more information, see “create custom fields” in the salesforce online help. how upsert chooses to insert or update upsert uses the sobject record's primary key (the id), an idlookup field, or an external id field to determine whether it should create a record or update an existing one: 5apex reference guide apex dml statements • if the key isn’t matched, a new object record is created. • if the key is
matched once, the existing object record is updated. • if the key is matched multiple times, an error is generated and the object record isn’t inserted or updated. example this example performs an upsert of a list of accounts. list<account> acctlist = new list<account>(); // fill the accounts list with some accounts try { upsert acctlist; } catch (dmlexception e) { } this next example performs an upsert of a list of accounts using a foreign key for matching existing records, if any. list<account> acctlist = new list<account>(); // fill the accounts list with some accounts try { // upsert using an external id field upsert acctlist myextidfield__c; } catch (dmlexception e) { } delete statement the delete dml operation deletes one or more existing sobject records, such as individual accounts or contacts, from your organization’s data. delete is analogous to the delete() statement in the soap api. syntax delete sobject delete sobject[] example the following example deletes all accounts that are named 'dotcom': account[] doomedaccts = [select id, name from account where name = 'dotcom']; try { delete doomedaccts; } catch (dmlexception e) { // process exception here } note: for more information on processing dmlexceptions, see bulk dml exception handling. 6apex reference guide apex dml statements undelete statement the undelete dml operation restores one or more existing sobject records, such as individual accounts or contacts, from your organization’s recycle bin. undelete is analogous to the undelete statement in sql. syntax undelete sobject | id undelete sobject[] | id[] example the following example undeletes an account named 'universal containers’. the all rows keyword queries all rows for both top level and aggregate relationships, including deleted records and archived activities. account[] savedaccts = [select id, name from account where name = 'universal containers' all rows]; try { undelete savedaccts; } catch (dmlexception e) { // process exception here } note: for more information on processing dmlexceptions, see bulk dml exception handling. merge statement the merge statement merges up to three records of the same sobject type into one of the records, deleting the others, and re-parenting any related records. note: this dml operation does not have a matching database system method. syntax merge sobject sobject merge sobject sobject[] merge sobject id merge sobject id[] the first parameter represents the master record into which the other records are to be merged. the second parameter represents the one or two other records that should be merged and then deleted. you can pass these other records into the merge statement as a single sobject record or id, or as a list of two sobject records or ids. example the following example merges two accounts named 'acme inc.' and 'acme' into a single record: list<account> ls = new list<account>{new account(name='acme inc.'),new account(name='acme')}; insert ls; account masteracct = [select id, name from account where name = 'acme inc.' limit 1]; 7apex reference guide apexpages namespace account mergeacct = [select id, name from account where name = 'acme' limit 1]; try { merge masteracct mergeacct; } catch (dmlexception e) { // process exception here } note: for more information on processing dmlexceptions, see bulk dml exception handling. apexpages namespace the apexpages namespace provides classes used in visualforce controllers. the following are the classes in the apexpages namespace. in this section: action class you can use apexpages.action to create an action method that you can use in a visualforce custom controller or controller extension. component class represents a dynamic visualforce component in apex. ideastandardcontroller class ideastandardcontroller objects offer ideas-specific functionality in addition to what is provided by the standardcontroller. ideastandardsetcontroller class ideastandardsetcontroller objects offer ideas-specific functionality in addition to what is provided by the standardsetcontroller. knowledgearticleversionstandardcontroller class
knowledgearticleversionstandardcontroller objects offer article-specific functionality in addition to what is provided by the standardcontroller. message class contains validation errors that occur when the user saves the page that uses a standard controller. standardcontroller class use a standardcontroller when defining an extension for a standard controller. standardsetcontroller class standardsetcontroller objects allow you to create list controllers similar to, or as extensions of, the pre-built visualforce list controllers provided by salesforce. action class you can use apexpages.action to create an action method that you can use in a visualforce custom controller or controller extension. 8apex reference guide action class namespace apexpages usage for example, you could create a saveover method on a controller extension that performs a custom save. instantiation the following code snippet illustrates how to instantiate a new apexpages.action object that uses the save action: apexpages.action saveaction = new apexpages.action('{!save}'); in this section: action constructors action methods action constructors the following are constructors for action. in this section: action(action) creates a new instance of the apexpages.action class using the specified action. action(action) creates a new instance of the apexpages.action class using the specified action. signature public action(string action) parameters action type: string the action. action methods the following are methods for action. all are instance methods. 9apex reference guide component class in this section: getexpression() returns the expression that is evaluated when the action is invoked. invoke() invokes the action. getexpression() returns the expression that is evaluated when the action is invoked. signature public string getexpression() return value type: string invoke() invokes the action. signature public system.pagereference invoke() return value type: system.pagereference component class represents a dynamic visualforce component in apex. namespace apexpages dynamic component properties the following are properties for component. in this section: childcomponents returns a reference to the child components for the component. 10apex reference guide component class expressions sets the content of an attribute using the expression language notation. the notation for this is expressions.name_of_attribute. facets sets the content of a facet to a dynamic component. the notation is facet.name_of_facet. childcomponents returns a reference to the child components for the component. signature public list <apexpages.component> childcomponents {get; set;} property value type: list<apexpages.component> example component.apex.pageblock pageblk = new component.apex.pageblock(); component.apex.pageblocksection pageblksection = new component.apex.pageblocksection(title='dummy header'); pageblk.childcomponents.add(pageblksection); expressions sets the content of an attribute using the expression language notation. the notation for this is expressions.name_of_attribute. signature public string expressions {get; set;} property value type: string example component.apex.inputfield inpfld = new component.apex.inputfield(); inpfield.expressions.value = '{!account.name}'; inpfield.expressions.id = '{!$user.firstname}'; facets sets the content of a facet to a dynamic component. the notation is facet.name_of_facet. 11apex reference guide ideastandardcontroller class signature public string facets {get; set;} property value type: string usage note: this property is only accessible by components that support facets. example component.apex.datatable mydt = new component.apex.datatable(); component.apex.outputtext footer = new component.apex.outputtext(value='footer copyright'); mydt.facets.footer = footer; ideastandardcontroller class ideastandardcontroller objects offer ideas-specific functionality in addition to what is provided by the standardcontroller. namespace apexpages usage a method in the ideastandardcontroller object is called by and operated on a particular instance of an ideastandardcontroller. note: the ideastandardsetcontroller and ideastandardcontroller classes are currently available through a limited release program. for information on enabling these classes for your organization
, contact your salesforce representative. in addition to the methods listed in this class, the ideastandardcontroller class inherits all the methods associated with the standardcontroller class. instantiation an ideastandardcontroller object cannot be instantiated. an instance can be obtained through a constructor of a custom extension controller when using the standard ideas controller. 12apex reference guide ideastandardcontroller class example the following example shows how an ideastandardcontroller object can be used in the constructor for a custom list controller. this example provides the framework for manipulating the comment list data before displaying it on a visualforce page. public class myideaextension { private final apexpages.ideastandardcontroller ideacontroller; public myideaextension(apexpages.ideastandardcontroller controller) { ideacontroller = (apexpages.ideastandardcontroller)controller; } public list<ideacomment> getmodifiedcomments() { ideacomment[] comments = ideacontroller.getcommentlist(); // modify comments here return comments; } } the following visualforce markup shows how the ideastandardcontroller example shown above can be used in a page. this page must be named detailpage for this example to work. note: for the visualforce page to display the idea and its comments, in the following example you need to specify the id of a specific idea (for example, /apex/detailpage?id=<ideaid>) whose comments you want to view. <!-- page named detailpage --> <apex:page standardcontroller="idea" extensions="myideaextension"> <apex:pageblock title="idea section"> <ideas:detailoutputlink page="detailpage" ideaid="{!idea.id}">{!idea.title} </ideas:detailoutputlink> <br/><br/> <apex:outputtext >{!idea.body}</apex:outputtext> </apex:pageblock> <apex:pageblock title="comments section"> <apex:datalist var="a" value="{!modifiedcomments}" id="list"> {!a.commentbody} </apex:datalist> <ideas:detailoutputlink page="detailpage" ideaid="{!idea.id}" pageoffset="-1">prev</ideas:detailoutputlink> | <ideas:detailoutputlink page="detailpage" ideaid="{!idea.id}" pageoffset="1">next</ideas:detailoutputlink> </apex:pageblock> </apex:page> see also: standardcontroller class ideastandardcontroller methods the following are instance methods for ideastandardcontroller. 13apex reference guide ideastandardsetcontroller class in this section: getcommentlist() returns the list of read-only comments from the current page. getcommentlist() returns the list of read-only comments from the current page. signature public ideacomment[] getcommentlist() return value type: ideacomment[] this method returns the following comment properties: • id • commentbody • createddate • createdby.id • createdby.communitynickname ideastandardsetcontroller class ideastandardsetcontroller objects offer ideas-specific functionality in addition to what is provided by the standardsetcontroller. namespace apexpages usage note: the ideastandardsetcontroller and ideastandardcontroller classes are currently available through a limited release program. for information on enabling these classes for your organization, contact your salesforce representative. in addition to the method listed above, the ideastandardsetcontroller class inherits the methods associated with the standardsetcontroller. note: the methods inherited from the standardsetcontroller cannot be used to affect the list of ideas returned by the getidealist method. instantiation an ideastandardsetcontroller object cannot be instantiated. an instance can be obtained through a constructor of a custom extension controller when using the standard list controller for ideas. 14apex reference guide ideastandardsetcontroller class example: displaying a profile page the following example shows how an ideastandardsetcontroller object can be used in the constructor for a custom list controller: public class myideaprofileextension { private final apexpages.ideastandardsetcontroller ideasetcontroller; public myideaprofileextension(apexpages.ideastandardsetcontroller controller) { ideasetcontroller = (apexpages.ideastandardsetcontroller)controller; } public list<idea> getmodifiedideas() { idea[] ideas =
ideasetcontroller.getidealist(); // modify ideas here return ideas; } } the following visualforce markup shows how the ideastandardsetcontroller example shown above and the <ideas:profilelistoutputlink> component can display a profile page that lists the recent replies, submitted ideas, and votes associated with a user. because this example does not identify a specific user id, the page automatically shows the profile page for the current logged in user. this page must be named profilepage in order for this example to work: <!-- page named profilepage --> <apex:page standardcontroller="idea" extensions="myideaprofileextension" recordsetvar="ideasetvar"> <apex:pageblock > <ideas:profilelistoutputlink sort="recentreplies" page="profilepage"> recent replies</ideas:profilelistoutputlink> | <ideas:profilelistoutputlink sort="ideas" page="profilepage">ideas submitted </ideas:profilelistoutputlink> | <ideas:profilelistoutputlink sort="votes" page="profilepage">ideas voted </ideas:profilelistoutputlink> </apex:pageblock> <apex:pageblock > <apex:datalist value="{!modifiedideas}" var="ideadata"> <ideas:detailoutputlink ideaid="{!ideadata.id}" page="viewpage"> {!ideadata.title}</ideas:detailoutputlink> </apex:datalist> </apex:pageblock> </apex:page> in the previous example, the <ideas:detailoutputlink> component links to the following visualforce markup that displays the detail page for a specific idea. this page must be named viewpage in order for this example to work: <!-- page named viewpage --> <apex:page standardcontroller="idea"> <apex:pageblock title="idea section"> <ideas:detailoutputlink page="viewpage" ideaid="{!idea.id}">{!idea.title} </ideas:detailoutputlink> <br/><br/> 15apex reference guide ideastandardsetcontroller class <apex:outputtext>{!idea.body}</apex:outputtext> </apex:pageblock> </apex:page> example: displaying a list of top, recent, and most popular ideas and comments the following example shows how an ideastandardsetcontroller object can be used in the constructor for a custom list controller: note: you must have created at least one idea for this example to return any ideas. public class myidealistextension { private final apexpages.ideastandardsetcontroller ideasetcontroller; public myidealistextension (apexpages.ideastandardsetcontroller controller) { ideasetcontroller = (apexpages.ideastandardsetcontroller)controller; } public list<idea> getmodifiedideas() { idea[] ideas = ideasetcontroller.getidealist(); // modify ideas here return ideas; } } the following visualforce markup shows how the ideastandardsetcontroller example shown above can be used with the <ideas:listoutputlink> component to display a list of recent, top, and most popular ideas and comments. this page must be named listpage in order for this example to work: <!-- page named listpage --> <apex:page standardcontroller="idea" extensions="myidealistextension" recordsetvar="ideasetvar"> <apex:pageblock > <ideas:listoutputlink sort="recent" page="listpage">recent ideas </ideas:listoutputlink> | <ideas:listoutputlink sort="top" page="listpage">top ideas </ideas:listoutputlink> | <ideas:listoutputlink sort="popular" page="listpage">popular ideas </ideas:listoutputlink> | <ideas:listoutputlink sort="comments" page="listpage">recent comments </ideas:listoutputlink> </apex:pageblock> <apex:pageblock > <apex:datalist value="{!modifiedideas}" var="ideadata"> <ideas:detailoutputlink ideaid="{!ideadata.id}" page="viewpage"> {!ideadata.title}</ideas:detailoutputlink> </apex:datalist> </ape
x:pageblock> </apex:page> 16apex reference guide ideastandardsetcontroller class in the previous example, the <ideas:detailoutputlink> component links to the following visualforce markup that displays the detail page for a specific idea. this page must be named viewpage. <!-- page named viewpage --> <apex:page standardcontroller="idea"> <apex:pageblock title="idea section"> <ideas:detailoutputlink page="viewpage" ideaid="{!idea.id}">{!idea.title} </ideas:detailoutputlink> <br/><br/> <apex:outputtext>{!idea.body}</apex:outputtext> </apex:pageblock> </apex:page> see also: standardsetcontroller class ideastandardsetcontroller methods the following are instance methods for ideastandardsetcontroller. in this section: getidealist() returns the list of read-only ideas in the current page set. getidealist() returns the list of read-only ideas in the current page set. signature public idea[] getidealist() return value type: idea[] usage you can use the <ideas:listoutputlink>, <ideas:profilelistoutputlink>, and <ideas:detailoutputlink> components to display profile pages as well as idea list and detail pages (see the examples below). the following is a list of properties returned by this method: • body • categories • category • createdby.communitynickname • createdby.id • createddate 17apex reference guide knowledgearticleversionstandardcontroller class • id • lastcommentdate • lastcomment.id • lastcomment.commentbody • lastcomment.createdby.communitynickname • lastcomment.createdby.id • numcomments • status • title • votetotal knowledgearticleversionstandardcontroller class knowledgearticleversionstandardcontroller objects offer article-specific functionality in addition to what is provided by the standardcontroller. namespace apexpages usage in addition to the method listed above, the knowledgearticleversionstandardcontroller class inherits all the methods associated with standardcontroller. note: though inherited, the edit, delete, and save methods don't serve a function when used with the knowledgearticleversionstandardcontroller class. example the following example shows how a knowledgearticleversionstandardcontroller object can be used to create a custom extension controller. in this example, you create a class named agentcontributionarticlecontroller that allows customer-support agents to see pre-populated fields on the draft articles they create while closing cases. prerequisites: 1. create an article type called faq. for instructions, see “create article types” in the salesforce online help. 2. create a text custom field called details. for instructions, see “add custom fields to article types” in the salesforce online help. 3. create a category group called geography and assign it to a category called usa. for instructions, see “create and modify category groups” and “add data categories to category groups” in the salesforce online help. 4. create a category group called topics and assign it a category called maintenance. /** custom extension controller for the simplified article edit page that appears when an article is created on the close-case page. */ public class agentcontributionarticlecontroller { // the constructor must take a apexpages.knowledgearticleversionstandardcontroller as an argument 18apex reference guide knowledgearticleversionstandardcontroller class public agentcontributionarticlecontroller( apexpages.knowledgearticleversionstandardcontroller ctl) { // this is the sobject for the new article. //it can optionally be cast to the proper article type. // for example, faq__kav article = (faq__kav) ctl.getrecord(); sobject article = ctl.getrecord(); // this returns the id of the case that was closed. string sourceid = ctl.getsourceid(); case c = [select subject, description from case where id=:sourceid]; // this overrides the default behavior of pre-filling the // title of the article with the subject of the closed case. article.put('title', 'from case: '+c.subject); article.put('details__c',c.description); // only one category per category group can be specified. ctl.selectdatacategory('geography','usa'); ctl.selectdatacategory('topics','main
tenance'); } } /** test class for the custom extension controller. */ @istest private class agentcontributionarticlecontrollertest { static testmethod void testagentcontributionarticlecontroller() { string casesubject = 'my test'; string casedesc = 'my test description'; case c = new case(); c.subject= casesubject; c.description = casedesc; insert c; string caseid = c.id; system.debug('created case: ' + caseid); apexpages.currentpage().getparameters().put('sourceid', caseid); apexpages.currentpage().getparameters().put('sfdc.override', '1'); apexpages.knowledgearticleversionstandardcontroller ctl = new apexpages.knowledgearticleversionstandardcontroller(new faq__kav()); new agentcontributionarticlecontroller(ctl); system.assertequals(caseid, ctl.getsourceid()); system.assertequals('from case: '+casesubject, ctl.getrecord().get('title')); system.assertequals(casedesc, ctl.getrecord().get('details__c')); } } if you created the custom extension controller for the purpose described in the previous example (that is, to modify submitted-via-case articles), complete the following steps after creating the class: 1. log into your salesforce organization and from setup, enter knowledge settings in the quick find box, then select knowledge settings. 19apex reference guide knowledgearticleversionstandardcontroller class 2. click edit. 3. assign the class to the use apex customization field. this associates the article type specified in the new class with the article type assigned to closed cases. 4. click save. in this section: knowledgearticleversionstandardcontroller constructors knowledgearticleversionstandardcontroller methods see also: standardcontroller class knowledgearticleversionstandardcontroller constructors the following are constructors for knowledgearticleversionstandardcontroller. in this section: knowledgearticleversionstandardcontroller(article) creates a new instance of the apexpages.knowledgearticleversionstandardcontroller class using the specified knowledge article. knowledgearticleversionstandardcontroller(article) creates a new instance of the apexpages.knowledgearticleversionstandardcontroller class using the specified knowledge article. signature public knowledgearticleversionstandardcontroller(sobject article) parameters article type: sobject the knowledge article, such as faq_kav. knowledgearticleversionstandardcontroller methods the following are instance methods for knowledgearticleversionstandardcontroller. in this section: getsourceid() returns the id for the source object record when creating a new article from another object. 20apex reference guide message class setdatacategory(categorygroup, category) specifies a default data category for the specified data category group when creating a new article. getsourceid() returns the id for the source object record when creating a new article from another object. signature public string getsourceid() return value type: string setdatacategory(categorygroup, category) specifies a default data category for the specified data category group when creating a new article. signature public void setdatacategory(string categorygroup, string category) parameters categorygroup type: string category type: string return value type: void message class contains validation errors that occur when the user saves the page that uses a standard controller. namespace apexpages usage when using a standard controller, all validation errors, both custom and standard, that occur when the user saves the page are automatically added to the page error collections. if an inputfield component is bound to the field with an error, the message is added to the component’s error collection. all messages are added to the page’s error collection. for more information, see validation rules and standard controllers in the visualforce developer's guide. if your application uses a custom controller or extension, you must use the message class for collecting errors. 21apex reference guide message class instantiation in a custom controller or controller extension, you can instantiate a message in one of these ways: • apexpages.message mymsg = new apexpages.message(apexpages.severity, summary); where apexpages.severity is the enum that determines how severe a message is, and summary is the string used to summarize the message. for example: apexpages.message mymsg = new apexpages.message(apexpages.severity.fatal, 'my error msg'); •
apexpages.message mymsg = new apexpages.message(apexpages.severity, summary, detail); where apexpages. severity is the enum that determines how severe a message is, summary is the string used to summarize the message, and detail is the string used to provide more detailed information about the error. apexpages.severity enum to specify the severity of the message, use the apexpages.severity enum values. the following are the valid values: • confirm • error • fatal • info • warning all enums have access to standard methods, such as name and value. in this section: message constructors message methods message constructors the following are constructors for message. in this section: message(severity, summary) creates a new instance of the apexpages.message class using the specified message severity and summary. message(severity, summary, detail) creates a new instance of the apexpages.message class using the specified message severity, summary, and message detail. message(severity, summary, detail, id) creates a new instance of the apexpages.message class using the specified severity, summary, detail, and component id. message(severity, summary) creates a new instance of the apexpages.message class using the specified message severity and summary. 22apex reference guide message class signature public message(apexpages.severity severity, string summary) parameters severity type: apexpages.severity the severity of a visualforce message. summary type: string the summary visualforce message. message(severity, summary, detail) creates a new instance of the apexpages.message class using the specified message severity, summary, and message detail. signature public message(apexpages.severity severity, string summary, string detail) parameters severity type: apexpages.severity the severity of a visualforce message. summary type: string the summary visualforce message. detail type: string the detailed visualforce message. message(severity, summary, detail, id) creates a new instance of the apexpages.message class using the specified severity, summary, detail, and component id. signature public message(apexpages.severity severity, string summary, string detail, string id) parameters severity type: apexpages.severity the severity of a visualforce message. 23apex reference guide message class summary type: string the summary visualforce message. detail type: string the detailed visualforce message. id type: string the id of the visualforce component to associate with the message, for example, a form field with an error. message methods the following are methods for message. all are instance methods. in this section: getcomponentlabel() returns the label of the associated inputfield component. if no label is defined, this method returns null. getdetail() returns the value of the detail parameter used to create the message. if no detail string was specified, this method returns null. getseverity() returns the severity enum used to create the message. getsummary() returns the summary string used to create the message. getcomponentlabel() returns the label of the associated inputfield component. if no label is defined, this method returns null. signature public string getcomponentlabel() return value type: string getdetail() returns the value of the detail parameter used to create the message. if no detail string was specified, this method returns null. signature public string getdetail() 24apex reference guide standardcontroller class return value type: string getseverity() returns the severity enum used to create the message. signature public apexpages.severity getseverity() return value type: apexpages.severity getsummary() returns the summary string used to create the message. signature public string getsummary() return value type: string standardcontroller class use a standardcontroller when defining an extension for a standard controller. namespace apexpages usage standardcontroller objects reference the pre-built visualforce controllers provided by salesforce. the only time it is necessary to refer to a standardcontroller object is when defining an extension for a standard controller. standardcontroller is the data type of the single argument in the extension class constructor. instantiation you can instantiate a standardcontroller in the following way: apexpages.standardcontroller sc = new apexpages.standardcontroller
(sobject); 25apex reference guide standardcontroller class example the following example shows how a standardcontroller object can be used in the constructor for a standard controller extension: public class mycontrollerextension { private final account acct; // the extension constructor initializes the private member // variable acct by using the getrecord method from the standard // controller. public mycontrollerextension(apexpages.standardcontroller stdcontroller) { this.acct = (account)stdcontroller.getrecord(); } public string getgreeting() { return 'hello ' + acct.name + ' (' + acct.id + ')'; } } the following visualforce markup shows how the controller extension from above can be used in a page: <apex:page standardcontroller="account" extensions="mycontrollerextension"> {!greeting} <p/> <apex:form> <apex:inputfield value="{!account.name}"/> <p/> <apex:commandbutton value="save" action="{!save}"/> </apex:form> </apex:page> in this section: standardcontroller constructors standardcontroller methods standardcontroller constructors the following are constructors for standardcontroller. in this section: standardcontroller(controllersobject) creates a new instance of the apexpages.standardcontroller class for the specified standard or custom object. standardcontroller(controllersobject) creates a new instance of the apexpages.standardcontroller class for the specified standard or custom object. signature public standardcontroller(sobject controllersobject) 26apex reference guide standardcontroller class parameters controllersobject type: sobject a standard or custom object. standardcontroller methods the following are methods for standardcontroller. all are instance methods. in this section: addfields(fieldnames) when a visualforce page is loaded, the fields accessible to the page are based on the fields referenced in the visualforce markup. this method adds a reference to each field specified in fieldnames so that the controller can explicitly access those fields as well. cancel() returns the pagereference of the cancel page. delete() deletes record and returns the pagereference of the delete page. edit() returns the pagereference of the standard edit page. getid() returns the id of the record that is currently in context, based on the value of the id query string parameter in the visualforce page url. getrecord() returns the record that is currently in context, based on the value of the id query string parameter in the visualforce page url. reset() forces the controller to reacquire access to newly referenced fields. any changes made to the record prior to this method call are discarded. save() saves changes and returns the updated pagereference. view() returns the pagereference object of the standard detail page. addfields(fieldnames) when a visualforce page is loaded, the fields accessible to the page are based on the fields referenced in the visualforce markup. this method adds a reference to each field specified in fieldnames so that the controller can explicitly access those fields as well. signature public void addfields(list<string> fieldnames) 27apex reference guide standardcontroller class parameters fieldnames type: list<string> return value type: void usage this method should be called before a record has been loaded—typically, it's called by the controller's constructor. if this method is called outside of the constructor, you must use the reset() method before calling addfields(). the strings in fieldnames can either be the api name of a field, such as accountid, or they can be explicit relationships to fields, such as something__r.myfield__c. this method is only for controllers used by dynamicvisualforce bindings. cancel() returns the pagereference of the cancel page. signature public system.pagereference cancel() return value type: system.pagereference delete() deletes record and returns the pagereference of the delete page. signature public system.pagereference delete() return value type: system.pagereference edit() returns the pagereference of the standard edit page. signature public system.pagereference edit() 28apex reference guide standardcontroller class return value type: system.pagereference getid() returns the id of the record that is currently in context, based on the value of the id query string parameter in the visualforce page url. signature public string getid() return value
type: string getrecord() returns the record that is currently in context, based on the value of the id query string parameter in the visualforce page url. signature public sobject getrecord() return value type: sobject usage note that only the fields that are referenced in the associated visualforce markup are available for querying on this sobject. all other fields, including fields from any related objects, must be queried using a soql expression. tip: you can work around this restriction by including a hidden component that references any additional fields that you want to query. hide the component from display by setting the component's rendered attribute to false. example <apex:outputtext value="{!account.billingcity} {!account.contacts}" rendered="false"/> reset() forces the controller to reacquire access to newly referenced fields. any changes made to the record prior to this method call are discarded. 29apex reference guide standardsetcontroller class signature public void reset() return value type: void usage this method is only used if addfields is called outside the constructor, and it must be called directly before addfields. this method is only for controllers used by dynamicvisualforce bindings. save() saves changes and returns the updated pagereference. signature public system.pagereference save() return value type: system.pagereference view() returns the pagereference object of the standard detail page. signature public system.pagereference view() return value type: system.pagereference standardsetcontroller class standardsetcontroller objects allow you to create list controllers similar to, or as extensions of, the pre-built visualforce list controllers provided by salesforce. namespace apexpages usage the standardsetcontroller class also contains a prototype object. this is a single sobject contained within the visualforce standardsetcontroller class. if the prototype object's fields are set, those values are used during the save action, meaning that the values 30apex reference guide standardsetcontroller class are applied to every record in the set controller's collection. this is useful for writing pages that perform mass updates (applying identical changes to fields within a collection of objects). note: fields that are required in other salesforce objects will keep the same requiredness when used by the prototype object. instantiation you can instantiate a standardsetcontroller in either of the following ways: • from a list of sobjects: list<account> accountlist = [select name from account limit 20]; apexpages.standardsetcontroller ssc = new apexpages.standardsetcontroller(accountlist); • from a query locator: apexpages.standardsetcontroller ssc = new apexpages.standardsetcontroller(database.getquerylocator([select name,closedate from opportunity])); note: the maximum record limit for standardsetcontroller is 10,000 records. instantiating standardsetcontroller using a query locator returning more than 10,000 records causes a limitexception to be thrown. however, instantiating standardsetcontroller with a list of more than 10,000 records doesn’t throw an exception, and instead truncates the records to the limit. example the following example shows how a standardsetcontroller object can be used in the constructor for a custom list controller: public class opportunitylist2con { // apexpages.standardsetcontroller must be instantiated // for standard list controllers public apexpages.standardsetcontroller setcon { get { if(setcon == null) { setcon = new apexpages.standardsetcontroller(database.getquerylocator( [select name, closedate from opportunity])); } return setcon; } set; } // initialize setcon and return a list of records public list<opportunity> getopportunities() { return (list<opportunity>) setcon.getrecords(); } } the following visualforce markup shows how the controller above can be used in a page: <apex:page controller="opportunitylist2con"> <apex:pageblock> <apex:pageblocktable value="{!opportunities}" var="o"> <apex:column value="{!o.name}"/> 31apex reference guide standardsetcontroller class <apex:column value="{!o.closedate}"/> </apex:pageblocktable> </apex:pageblock> </apex:page> in this section: standardsetcontroller constructors standardsetcontroller methods
standardsetcontroller constructors the following are constructors for standardsetcontroller. in this section: standardsetcontroller(querylocator) creates an instance of the apexpages.standardsetcontroller class for the list of objects returned by the query locator. standardsetcontroller(controllersobjects) creates an instance of the apexpages.standardsetcontroller class for the specified list of standard or custom objects. standardsetcontroller(querylocator) creates an instance of the apexpages.standardsetcontroller class for the list of objects returned by the query locator. signature public standardsetcontroller(database.querylocator querylocator) parameters querylocator type: database.querylocator a query locator representing a list of sobjects. standardsetcontroller(controllersobjects) creates an instance of the apexpages.standardsetcontroller class for the specified list of standard or custom objects. signature public standardsetcontroller(list<sobject> controllersobjects) parameters controllersobjects type: list on page 3123<sobject on page 3313> a list of standard or custom objects. 32
apex reference guide standardsetcontroller class example list<account> accountlist = [select name from account limit 20]; apexpages.standardsetcontroller ssc = new apexpages.standardsetcontroller(accountlist); standardsetcontroller methods the following are methods for standardsetcontroller. all are instance methods. in this section: cancel() returns the pagereference of the original page, if known, or the home page. first() returns the first page of records. getcompleteresult() indicates whether there are more records in the set than the maximum record limit. if this is false, there are more records than you can process using the list controller. the maximum record limit is 10,000 records. getfilterid() returns the id of the filter that is currently in context. gethasnext() indicates whether there are more records after the current page set. gethasprevious() indicates whether there are more records before the current page set. getlistviewoptions() returns a list of the listviews available to the current user. getpagenumber() returns the page number of the current page set. note that the first page returns 1. getpagesize() returns the number of records included in each page set. getrecord() returns the sobject that represents the changes to the selected records. this retrieves the prototype object contained within the class, and is used for performing mass updates. getrecords() returns the list of sobjects in the current page set. this list is immutable, i.e. you can't call clear() on it. getresultsize() returns the number of records in the set. getselected() returns the list of sobjects that have been selected. last() returns the last page of records. next() returns the next page of records. 33apex reference guide standardsetcontroller class previous() returns the previous page of records. save() inserts new records or updates existing records that have been changed. after this operation is finished, it returns a pagereference to the original page, if known, or the home page. setfilterid(filterid) sets the filter id of the controller. setpagenumber(pagenumber) sets the page number. setpagesize(pagesize) sets the number of records in each page set. setselected(selectedrecords) set the selected records. cancel() returns the pagereference of the original page, if known, or the home page. signature public system.pagereference cancel() return value type: system.pagereference first() returns the first page of records. signature public void first() return value type: void getcompleteresult() indicates whether there are more records in the set than the maximum record limit. if this is false, there are more records than you can process using the list controller. the maximum record limit is 10,000 records. signature public boolean getcompleteresult() 34apex reference guide standardsetcontroller class return value type: boolean getfilterid() returns the id of the filter that is currently in context. signature public string getfilterid() return value type: string gethasnext() indicates whether there are more records after the current page set. signature public boolean gethasnext() return value type: boolean gethasprevious() indicates whether there are more records before the current page set. signature public boolean gethasprevious() return value type: boolean getlistviewoptions() returns a list of the listviews available to the current user. signature public system.selectoption getlistviewoptions() return value type: system.selectoption[] 35apex reference guide standardsetcontroller class getpagenumber() returns the page number of the current page set. note that the first page returns 1. signature public integer getpagenumber() return value type: integer getpagesize() returns the number of records included in each page set. signature public integer getpagesize() return value type: integer getrecord() returns the sobject that represents the changes to the selected records. this retrieves the prototype object contained within the class, and is used for performing mass updates. signature public sobject getrecord() return value type: sobject getrecords() returns the list of sobjects in the current page set. this list is immutable, i.e. you can't call clear() on it. signature public sobject[] getrec
ords() return value type: sobject[] 36apex reference guide standardsetcontroller class getresultsize() returns the number of records in the set. signature public integer getresultsize() return value type: integer getselected() returns the list of sobjects that have been selected. signature public sobject[] getselected() return value type: sobject[] last() returns the last page of records. signature public void last() return value type: void next() returns the next page of records. signature public void next() return value type: void previous() returns the previous page of records. 37apex reference guide standardsetcontroller class signature public void previous() return value type: void save() inserts new records or updates existing records that have been changed. after this operation is finished, it returns a pagereference to the original page, if known, or the home page. signature public system.pagereference save() return value type: system.pagereference setfilterid(filterid) sets the filter id of the controller. signature public void setfilterid(string filterid) parameters filterid type: string return value type: void setpagenumber(pagenumber) sets the page number. signature public void setpagenumber(integer pagenumber) parameters pagenumber type: integer 38apex reference guide applauncher namespace return value type: void setpagesize(pagesize) sets the number of records in each page set. signature public void setpagesize(integer pagesize) parameters pagesize type: integer return value type: void setselected(selectedrecords) set the selected records. signature public void setselected(sobject[] selectedrecords) parameters selectedrecords type: sobject[] return value type: void applauncher namespace the applauncher namespace provides methods for managing the appearance of apps in the app launcher, including their visibility and sort order. the following class is in the applauncher namespace. in this section: appmenu class contains methods to set the appearance of apps in the app launcher. 39apex reference guide appmenu class communitylogocontroller class represents the logo of the experience cloud site. for internal use only. employeeloginlinkcontroller class represents the link on the login form that employees can click to log in. for internal use only. sociallogincontroller class represents the social authentication providers configured for the experience cloud site. for internal use only. appmenu class contains methods to set the appearance of apps in the app launcher. namespace applauncher in this section: appmenu methods appmenu methods the following are methods for appmenu. in this section: setappvisibility(appmenuitemid, isvisible) shows or hides specific apps in the app launcher. setorgsortorder(appids) sets the organization-wide default sort order for the app launcher based on a list of app menu item ids in the desired order. setusersortorder(appids) sets an individual user’s default sort order for the app launcher based on a list of app menu item ids in the desired order. setappvisibility(appmenuitemid, isvisible) shows or hides specific apps in the app launcher. signature public static void setappvisibility(id appmenuitemid, boolean isvisible) parameters appmenuitemid type: id the 15-character application id value for an app. for more information, see the applicationid field for appmenuitem or the appmenuitemid field for userappmenuitem in the salesforce object reference 40apex reference guide communitylogocontroller class isvisible type: boolean if true, the app is visible. return value type: void setorgsortorder(appids) sets the organization-wide default sort order for the app launcher based on a list of app menu item ids in the desired order. signature public static void setorgsortorder(list<id> appids) parameters appids type: list<id> a list of application id values. for more information, see the applicationid field for appmenuitem in the salesforce object reference. return value type: void setusersortorder(appids) sets an individual user�
�s default sort order for the app launcher based on a list of app menu item ids in the desired order. signature public static void setusersortorder(list<id> appids) parameters appids type: list<id> a list of application id values. for more information, see the appmenuitemid field for userappmenuitem in the salesforce object reference. return value type: void communitylogocontroller class represents the logo of the experience cloud site. for internal use only. 41apex reference guide employeeloginlinkcontroller class namespace applauncher in this section: communitylogocontroller methods communitylogocontroller methods the following are methods for communitylogocontroller. in this section: getcommunityname() returns the name of the experience cloud site. getlogourl() returns the path to the page containing the experience cloud site’s logo. getcommunityname() returns the name of the experience cloud site. signature public static string getcommunityname() return value type: string getlogourl() returns the path to the page containing the experience cloud site’s logo. signature public static string getlogourl() return value type: string employeeloginlinkcontroller class represents the link on the login form that employees can click to log in. for internal use only. namespace applauncher 42apex reference guide sociallogincontroller class in this section: employeeloginlinkcontroller methods employeeloginlinkcontroller methods the following are methods for employeeloginlinkcontroller. in this section: getemployeeloginurl(starturl) returns the path to the page that employees see after they log in. getisallowinternaluserloginenabled() indicates whether an internal user is allowed to log in to the experience cloud site. getemployeeloginurl(starturl) returns the path to the page that employees see after they log in. signature public static string getemployeeloginurl(string starturl) parameters starturl type: string path to the page that employees see after they log in. return value type: string getisallowinternaluserloginenabled() indicates whether an internal user is allowed to log in to the experience cloud site. signature public static boolean getisallowinternaluserloginenabled() return value type: boolean sociallogincontroller class represents the social authentication providers configured for the experience cloud site. for internal use only. 43apex reference guide sociallogincontroller class namespace applauncher in this section: sociallogincontroller methods sociallogincontroller methods the following are methods for sociallogincontroller. in this section: getcommunitydomainssourl(starturl, developername) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. getsamlssourl(starturl, samlid) returns the url to the saml provider for the experience cloud site. getsamlssourlnocache(starturl, samlid) returns the url to the saml provider for the experience cloud site, without caching the url. calling this method also initiates a backend call. getssourl(starturl, developername) returns the single sign-on url for the experience cloud site. getcommunitydomainssourl(starturl, developername) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. note: for better performance, we recommend using this method instead of getauthproviderssourl. if the authentication provider has use subdomain for callback enabled, changing the single sign-on url also changes the callback url to the experience cloud site subdomain. before switching to this method, update the callback url in your third-party applications to avoid getting an invalid callback url error during single sign-on. signature public static string getcommunitydomainssourl(string starturl, string developername) parameters starturl type: string the page that you see after successfully logging into the experience cloud site or my domain subdomain. developername type: string the unique name of the authentication provider. 44apex reference guide sociallogincontroller class return value type: string getsamlssourl(starturl, samlid) returns the url to the saml provider for the experience cloud site. signature public static string getsamlssourl(string starturl, string samlid) parameters starturl type: string path to the page that users see
when they access the experience cloud site. samlid type: string unique identifier of the saml provider. return value type: string getsamlssourlnocache(starturl, samlid) returns the url to the saml provider for the experience cloud site, without caching the url. calling this method also initiates a backend call. signature public static string getsamlssourlnocache(string starturl, string samlid) parameters starturl type: string path to the page that users see when they access the experience cloud site. samlid type: string unique identifier of the saml provider. return value type: string the url to the site's saml provider. unlike the url returned by the getsamlssourl method, this url isn't cached. 45apex reference guide approval namespace getssourl(starturl, developername) returns the single sign-on url for the experience cloud site. signature public static string getssourl(string starturl, string developername) parameters starturl type: string path to the page that users see when they access the experience cloud site. developername type: string unique name of the authentication provider. return value type: string approval namespace the approval namespace provides classes and methods for approval processes. the following are the classes in the approval namespace. in this section: lockresult class the result of a record lock returned by a system.approval.lock() method. processrequest class the processrequest class is the parent class for the processsubmitrequest and processworkitemrequest classes. use the processrequest class to write generic apex that can process objects from either class. processresult class after you submit a record for approval, use the processresult class to process the results of an approval process. processsubmitrequest class use the processsubmitrequest class to submit a record for approval. processworkitemrequest class use the processworkitemrequest class for processing an approval request after it is submitted. unlockresult class the result of a record unlock, returned by a system.approval.unlock() method. lockresult class the result of a record lock returned by a system.approval.lock() method. 46apex reference guide lockresult class namespace approval usage the system.approval.lock() methods return approval.lockresult objects. each element in a lockresult array corresponds to an element in the id or sobject array passed as a parameter to a lock method. the first element in the lockresult array corresponds to the first element in the id or sobject array, the second element corresponds to the second element, and so on. if only one id or sobject is passed in, the lockresult array contains a single element. example the following example obtains and iterates through the returned approval.lockresult objects. it locks some queried accounts using approval.lock with a false second parameter to allow partial processing of records on failure. next, it iterates through the results to determine whether the operation was successful for each record. it writes the id of every record that was processed successfully to the debug log, or writes error messages and failed fields of the failed records. // query the accounts to lock account[] accts = [select id from account where name like 'acme%']; // lock the accounts approval.lockresult[] lrlist = approval.lock(accts, false); // iterate through each returned result for(approval.lockresult lr : lrlist) { if (lr.issuccess()) { // operation was successful, so get the id of the record that was processed system.debug('successfully locked account with id: ' + lr.getid()); } else { // operation failed, so get all errors for(database.error err : lr.geterrors()) { system.debug('the following error has occurred.'); system.debug(err.getstatuscode() + ': ' + err.getmessage()); system.debug('account fields that affected this error: ' + err.getfields()); } } } in this section: lockresult methods see also: approval class lockresult methods the following are methods for lockresult. 47apex reference guide lockresult class in this section: geterrors() if an error occurred, returns an array of one or more database error objects, providing the error code and description. getid()
returns the id of the sobject you are trying to lock. issuccess() a boolean value that is set to true if the lock operation is successful for this object, or false otherwise. geterrors() if an error occurred, returns an array of one or more database error objects, providing the error code and description. signature public list<database.error> geterrors() return value type: list<database.error> getid() returns the id of the sobject you are trying to lock. signature public id getid() return value type: id usage if the field contains a value, the object was locked. if the field is empty, the operation was not successful. issuccess() a boolean value that is set to true if the lock operation is successful for this object, or false otherwise. signature public boolean issuccess() return value type: boolean 48apex reference guide processrequest class processrequest class the processrequest class is the parent class for the processsubmitrequest and processworkitemrequest classes. use the processrequest class to write generic apex that can process objects from either class. namespace approval usage the request must be instantiated via the child classes, processsubmitrequest and processworkitemrequest. processrequest methods the following are methods for processrequest. all are instance methods. in this section: getcomments() returns the comments that have been added previously to the approval request. getnextapproverids() returns the list of user ids of user specified as approvers. setcomments(comments) sets the comments to be added to the approval request. setnextapproverids(nextapproverids) if the next step in your approval process is another apex approval process, you specify exactly one user id as the next approver. if not, you cannot specify a user id and this method must be null. getcomments() returns the comments that have been added previously to the approval request. signature public string getcomments() return value type: string getnextapproverids() returns the list of user ids of user specified as approvers. signature public id[] getnextapproverids() 49apex reference guide processresult class return value type: id[] setcomments(comments) sets the comments to be added to the approval request. signature public void setcomments(string comments) parameters comments type: string return value type: void setnextapproverids(nextapproverids) if the next step in your approval process is another apex approval process, you specify exactly one user id as the next approver. if not, you cannot specify a user id and this method must be null. signature public void setnextapproverids(id[] nextapproverids) parameters nextapproverids type: id[] must be a single-entry list. return value type: void processresult class after you submit a record for approval, use the processresult class to process the results of an approval process. namespace approval 50apex reference guide processresult class usage a processresult object is returned by the process method. you must specify the approval namespace when creating an instance of this class. for example: approval.processresult result = approval.process(req1); processresult methods the following are methods for processresult. all are instance methods. in this section: getentityid() the id of the record being processed. geterrors() if an error occurred, returns an array of one or more database error objects including the error code and description. getinstanceid() the id of the approval process that has been submitted for approval. getinstancestatus() the status of the current approval process. valid values are: approved, rejected, removed or pending. getnewworkitemids() the ids of the new items submitted to the approval process. there can be 0 or 1 approval processes. issuccess() a boolean value that is set to true if the approval process completed successfully; otherwise, it is set to false. getentityid() the id of the record being processed. signature public string getentityid() return value type: string geterrors() if an error occurred, returns an array of one or more database error objects including the error code and description. signature public database.error[] geterrors() 51apex reference guide processresult class return value type
: database.error[] getinstanceid() the id of the approval process that has been submitted for approval. signature public string getinstanceid() return value type: string getinstancestatus() the status of the current approval process. valid values are: approved, rejected, removed or pending. signature public string getinstancestatus() return value type: string getnewworkitemids() the ids of the new items submitted to the approval process. there can be 0 or 1 approval processes. signature public id[] getnewworkitemids() return value type: id[] issuccess() a boolean value that is set to true if the approval process completed successfully; otherwise, it is set to false. signature public boolean issuccess() return value type: boolean 52apex reference guide processsubmitrequest class processsubmitrequest class use the processsubmitrequest class to submit a record for approval. namespace approval usage you must specify the approval namespace when creating an instance of this class. the constructor for this class takes no arguments. for example: approval.processsubmitrequest psr = new approval.processsubmitrequest(); inherited methods in addition to the methods listed, the processsubmitrequest class has access to all the methods in its parent class, processrequest class. • getcomments() • getnextapproverids() • setcomments(comments) • setnextapproverids(nextapproverids) example to view sample code, refer to approval processing example. processsubmitrequest methods the following are methods for processsubmitrequest. all are instance methods. in this section: getobjectid() returns the id of the record that has been submitted for approval. for example, it can return an account, contact, or custom object record. getprocessdefinitionnameorid() returns the developer name or id of the process definition. getskipentrycriteria() if getprocessdefinitionnameorid() returns a value other than null, getskipentrycriteria() determines whether to evaluate the entry criteria for the process (true) or not (false). getsubmitterid() returns the user id of the submitter requesting the approval record. the user must be one of the allowed submitters in the process definition setup. 53apex reference guide processsubmitrequest class setobjectid(recordid) sets the id of the record to be submitted for approval. for example, it can specify an account, contact, or custom object record. setprocessdefinitionnameorid(nameorid) sets the developer name or id of the process definition to be evaluated. setskipentrycriteria(skipentrycriteria) if the process definition name or id is not null, setskipentrycriteria() determines whether to evaluate the entry criteria for the process (true) or not (false). setsubmitterid(userid) sets the user id of the submitter requesting the approval record. the user must be one of the allowed submitters in the process definition setup. if you don’t set a submitter id, the process uses the current user as the submitter. getobjectid() returns the id of the record that has been submitted for approval. for example, it can return an account, contact, or custom object record. signature public string getobjectid() return value type: string getprocessdefinitionnameorid() returns the developer name or id of the process definition. signature public string getprocessdefinitionnameorid() return value type: string usage the default is null. if the return value is null, when a user submits a record for approval salesforce evaluates the entry criteria for all processes applicable to the user. getskipentrycriteria() if getprocessdefinitionnameorid() returns a value other than null, getskipentrycriteria() determines whether to evaluate the entry criteria for the process (true) or not (false). signature public boolean getskipentrycriteria() 54apex reference guide processsubmitrequest class return value type: boolean getsubmitterid() returns the user id of the submitter requesting the approval record. the user must be one of the allowed submitters in the process definition setup. signature public string getsubmitterid() return value type: string setobjectid(recordid) sets the id of the record to be submitted for approval. for example, it can specify an account, contact, or custom object record. signature public void setobjectid
(string recordid) parameters recordid type: string return value type: void setprocessdefinitionnameorid(nameorid) sets the developer name or id of the process definition to be evaluated. signature public void setprocessdefinitionnameorid(string nameorid) parameters nameorid type: string the process definition developer name or process definition id. the record is submitted to this specific process. if set to null, submission of a record approval follows standard evaluation; that is, every entry criteria of the process definition in the process order is evaluated and the one that satisfies is picked and submitted. 55apex reference guide processsubmitrequest class return value type: void usage if the process definition name or id is not set via this method, then by default it is null. if it is null, the submission of a record for approval evaluates entry criteria for all processes applicable to the submitter. the order of evaluation is based on the process order of the setup. setskipentrycriteria(skipentrycriteria) if the process definition name or id is not null, setskipentrycriteria() determines whether to evaluate the entry criteria for the process (true) or not (false). signature public void setskipentrycriteria(boolean skipentrycriteria) parameters skipentrycriteria type: boolean if set to true, request submission skips the evaluation of entry criteria for the process set in setprocessdefinitionnameorid(nameorid). if the process definition name or id is not specified, this parameter is ignored and standard evaluation is followed based on process order. if set to false, or if this method isn’t called, the entry criteria is not skipped. return value type: void setsubmitterid(userid) sets the user id of the submitter requesting the approval record. the user must be one of the allowed submitters in the process definition setup. if you don’t set a submitter id, the process uses the current user as the submitter. signature public void setsubmitterid(string userid) parameters userid type: string the user id on behalf of which the record is submitted. if set to null, the current user is the submitter. if the submitter is not set with this method, the default submitter is null (the current user). return value type: void 56apex reference guide processworkitemrequest class processworkitemrequest class use the processworkitemrequest class for processing an approval request after it is submitted. namespace approval usage you must specify the approval namespace when creating an instance of this class. the constructor for this class takes no arguments. for example: approval.processworkitemrequest pwr = new approval.processworkitemrequest(); inherited methods in addition to the methods listed, the processworkitemrequest class has access to all the methods in its parent class, processrequest class: • getcomments() • getnextapproverids() • setcomments(comments) • setnextapproverids(nextapproverids) processworkitemrequest methods the following are methods for processworkitemrequest. all are instance methods. in this section: getaction() returns the type of action already associated with the approval request. valid values are: approve, reject, or removed. getworkitemid() returns the id of the approval request that is in the process of being approved, rejected, or removed. setaction(actiontype) sets the type of action to take for processing an approval request. setworkitemid(id) sets the id of the approval request that is being approved, rejected, or removed. getaction() returns the type of action already associated with the approval request. valid values are: approve, reject, or removed. signature public string getaction() 57apex reference guide processworkitemrequest class return value type: string getworkitemid() returns the id of the approval request that is in the process of being approved, rejected, or removed. signature public string getworkitemid() return value type: string setaction(actiontype) sets the type of action to take for processing an approval request. signature public void setaction(string actiontype) parameters actiontype type: string valid values are: approve, reject, or removed. only system administrators can specify removed. return value type: void setworkitemid(id) sets the id of the
approval request that is being approved, rejected, or removed. signature public void setworkitemid(string id) parameters id type: string return value type: void 58apex reference guide unlockresult class unlockresult class the result of a record unlock, returned by a system.approval.unlock() method. namespace approval usage the system.approval.unlock() methods return approval.unlockresult objects. each element in an unlockresult array corresponds to an element in the id or sobject array passed as a parameter to an unlock method. the first element in the unlockresult array corresponds to the first element in the id or sobject array, the second element corresponds to the second element, and so on. if only one id or sobject is passed in, the unlockresult array contains a single element. example the following example shows how to obtain and iterate through the returned approval.unlockresult objects. it locks some queried accounts using approval.unlock with a false second parameter to allow partial processing of records on failure. next, it iterates through the results to determine whether the operation was successful for each record. it writes the id of every record that was processed successfully to the debug log, or writes error messages and failed fields of the failed records. // query the accounts to unlock account[] accts = [select id from account where name like 'acme%']; for(account acct:accts) { // create an approval request for the account approval.processsubmitrequest req1 = new approval.processsubmitrequest(); req1.setcomments('submitting request for approval.'); req1.setobjectid(acct.id); // submit the record to specific process and skip the criteria evaluation req1.setprocessdefinitionnameorid('pto_request_process'); req1.setskipentrycriteria(true); // submit the approval request for the account approval.processresult result = approval.process(req1); // verify the result system.assert(result.issuccess()); } // unlock the accounts approval.unlockresult[] urlist = approval.unlock(accts, false); // iterate through each returned result for(approval.unlockresult ur : urlist) { if (ur.issuccess()) { // operation was successful, so get the id of the record that was processed system.debug('successfully unlocked account with id: ' + ur.getid()); } 59apex reference guide unlockresult class else { // operation failed, so get all errors for(database.error err : ur.geterrors()) { system.debug('the following error has occurred.'); system.debug(err.getstatuscode() + ': ' + err.getmessage()); system.debug('account fields that affected this error: ' + err.getfields()); } } } in this section: unlockresult methods see also: approval class unlockresult methods the following are methods for unlockresult. in this section: geterrors() if an error occurred, returns an array of one or more database error objects, providing the error code and description. getid() returns the id of the sobject you are trying to unlock. issuccess() a boolean value that is set to true if the unlock operation is successful for this object, or false otherwise. geterrors() if an error occurred, returns an array of one or more database error objects, providing the error code and description. signature public list<database.error> geterrors() return value type: list<database.error> getid() returns the id of the sobject you are trying to unlock. signature public id getid() 60apex reference guide auth namespace return value type: id usage if the field contains a value, the object was unlocked. if the field is empty, the operation was not successfult. issuccess() a boolean value that is set to true if the unlock operation is successful for this object, or false otherwise. signature public boolean issuccess() return value type: boolean auth namespace the auth namespace provides an interface and classes for single sign-on into salesforce and session security management. the following is the interface in the auth namespace. in this section: authconfiguration class contains methods for configuring settings for users to log in to a salesforce org using their authentication provider credentials
instead of their salesforce credentials. the authentication provider can be any authentication provider that supports the openid connect protocol, such as google, facebook, or twitter. users log in to either an experience cloud site (https://mydomainname.my.site.com) or your my domain login url (https://mydomainname.my.salesforce.com). authprovidercallbackstate class provides request http headers, body, and query parameters to the authproviderplugin.handlecallback method for user authentication. this class allows you to group the information passed in rather than passing headers, body, and query parameters individually. authproviderplugin interface this interface is deprecated. for new development, use the abstract class auth.authproviderpluginclass to create a custom oauth-based authentication provider plug-in for single sign-on in to salesforce. authproviderpluginclass class contains methods to create a custom oauth-based authentication provider plug-in for single sign-on in to salesforce. use this class to create a custom authentication provider plug-in if you can’t use one of the authentication providers that salesforce provides. authprovidertokenresponse class stores the response from the authproviderplugin.handlecallback method. 61apex reference guide auth namespace authtoken class contains methods for providing the access token associated with an authentication provider for an authenticated user, except for the janrain provider. communitiesutil class contains methods for getting information about an experience cloud user. configurableselfreghandler interface gives you more control over how customers or partners self-register for your experience cloud site by creating a class that implements auth.configurableselfreghandler. you choose the user information to collect, and how users identify themselves—with their email address, phone number, or another identifier. when verified, you create a customer or partner user and log in the user to your experience cloud site. confirmuserregistrationhandler interface manages single sign-on (sso) user mappings between salesforce and a third-party identity provider. use this interface to confirm user mappings before updating them. connectedappplugin class contains methods for extending the behavior of a connected app, for example, customizing how a connected app is invoked depending on the protocol used. this class gives you more control over the interaction between salesforce and your connected app. headlessselfregistrationhandler interface creates customer and partner users during the headless registration flow. invocationcontext enum the context in which the connected app is invoked, such as the protocol flow used and the token type issued, if any. developers can use the context information to write code that is unique to the type of invocation. jws class contains methods that apply a digital signature to a json web token (jwt), using a json web signature (jws) data structure. this class creates the signed jwt bearer token, which can be used to request an oauth access token in the oauth 2.0 jwt bearer token flow. jwt class generates the json claims set in a json web token (jwt). the resulting base64-encoded payload can be passed as an argument to create an instance of the auth.jws class. jwtbearertokenexchange class contains methods that post the signed jwt bearer token to a token endpoint to request an access token, in the oauth 2.0 jwt bearer token flow. lightninglogineligibility enum contains a lightning login eligibility value used by the auth.sessionmanagement.getlightninglogineligibility method. logindiscoveryhandler interface salesforce gives you the ability to log in users based on other verification methods than username and password. for example, it can prompt users to log in with their email, phone number, or another identifier like a federation id or device identifier. login discovery is available to these licenses: customer community, customer community plus, external identity, partner community, and partner community plus. logindiscoverymethod enum contains methods used to verify the user’s identity when the my domain login process uses login discovery. 62apex reference guide authconfiguration class mydomainlogindiscoveryhandler interface the handler used to implement the my domain login discovery page, which is an interview-based (two-step) login process. first the user is prompted for a unique identifier such as an email address or phone number. then the handler determines (discovers) how to authenticate the user. either the user enters a password or is directed to an identity provider’s login page. oauthrefreshresult class stores the result of an authproviderpluginclass refresh method. oauth authentication
flow provides a refresh token that can be used to get a new access token. access tokens have a limited lifetime as specified by the session timeout value. when an access token expires, use a refresh token to get a new access token. registrationhandler interface salesforce provides the ability to use an authentication provider, such as facebook© or janrain©, for single sign-on into salesforce. samljithandler interface use this interface to control and customize just-in-time user provisioning logic during saml single sign-on. sessionmanagement class contains methods for verifying users’ identity, creating custom login flows, customizing security levels, and defining trusted ip ranges for a current session. sessionlevel enum an auth.sessionlevel enum value is used by the sessionmanagement.setsessionlevel method. userdata class stores user information for auth.registrationhandler. verificationmethod enum contains the different ways users can identify themselves when logging in. you can use it to implement mobile-centric passwordless login pages and to self-register (and deregister) verification methods. verificationpolicy enum the auth.verificationpolicy enum contains an identity verification policy value used by the sessionmanagement.generateverificationurl method. verificationresult class contains the result of a verification challenge that you invoke when you create your own verify page. the challenge can be initiated by either the system.usermanagement.verifypasswordlesslogin or system.usermanagement.verifyselfregistration method. auth exceptions the auth namespace contains some exception classes. authconfiguration class contains methods for configuring settings for users to log in to a salesforce org using their authentication provider credentials instead of their salesforce credentials. the authentication provider can be any authentication provider that supports the openid connect protocol, such as google, facebook, or twitter. users log in to either an experience cloud site (https://mydomainname.my.site.com) or your my domain login url (https://mydomainname.my.salesforce.com). namespace auth 63apex reference guide authconfiguration class example this example shows how to call some methods on the auth.authconfiguration class. before you can run this sample, you must provide valid values for the urls and developer name. note: if you’re not using enhanced domains, your org’s my domain urls are different. for details, see my domain url formats in salesforce help. string communityurl = 'mydomainname.my.site.com'; string starturl = '<add url>'; auth.authconfiguration authconfig = new auth.authconfiguration(communityurl,starturl); list<authprovider> authprvs = authconfig.getauthproviders(); string bcolor = authconfig.getbackgroundcolor(); string ftext = authconfig.getfootertext(); string sso = auth.authconfiguration.getauthproviderssourl(communityurl, starturl, 'developername'); authconfiguration constructors the following are constructors for authconfiguration. note: the authconfiguration (networkid, starturl) constructor is deprecated in api version 56.0 and later. authconfiguration(communityorcustomurl, starturl) creates an instance of the authconfiguration class using the specified url for an experience cloud site or a my domain subdomain and the start url for authenticated users. signature public authconfiguration(string communityorcustomurl, string starturl) parameters communityorcustomurl type: string the url for the domain, which can be a salesforce subdomain created with my domain (my.salesforce.com) or a subdomain of an experience cloud site (force.com). starturl type: string the page users see after successfully logging in to the experience cloud site or my domain subdomain. authconfiguration methods the following are methods for authconfiguration. use these methods to manage and customize authentication for a salesforce community. 64apex reference guide authconfiguration class in this section: getallowinternaluserloginenabled() indicates whether the experience cloud site allows internal users to log in using the experience cloud site login page. to enable, admins configure the setting allow internal users to log in directly to the experience on the login & registration page in experience workspaces. it’s disabled by default. getauthconfig() returns the authconfig sobject, which represents the authentication options for an experience cloud site or salesforce my domain subdomain. getauthconfigproviders() returns the list of authentication providers configured for an experience cloud site or salesforce my domain subdomain. getauthproviders() returns
the list of authentication providers available for an experience cloud site or salesforce my domain subdomain. getauthproviderssodomainurl(communityurl, starturl, developername) returns the single sign-on url for an experience cloud site subdomain. getauthproviderssourl(communityurl, starturl, developername) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. getbackgroundcolor() returns the color for the background of the login page for a community. getcertificateloginenabled(domainurl) returns true if certificate-based authentication is enabled for the my domain url. getcertificateloginurl(domainurl, starturl) returns the certificate-based authentication endpoint for the my domain url if the org has certificate-based authentication enabled. getdefaultprofileforregistration() returns the profile id assigned to new community users. getfootertext() returns the text at the bottom of the login page for a community. getforgotpasswordurl() returns the url for the standard or custom forgot password page that is specified for an experience cloud site or portal by the administrator. getheadlessforgotpasswordenabled() returns true if the headless forgot password flow is enabled. getheadlessfrgtpswenabled() this method will be deprecated in a future release. use the getheadlessforgotpasswordenabled() method in this class instead. getheadlessregistrationenabled() determines if the headless registration flow is enabled. getlogourl() returns the location of the icon image at the bottom of the login page for a community. getrightframeurl() returns the url for the right-frame content to display on the right side of the experience cloud site login page. the admin supplies the url. 65apex reference guide authconfiguration class getsamlproviders() returns the list of saml-based authentication providers available for an experience cloud site or salesforce my domain subdomain. getsamlssourl(communityurl, starturl, samlid) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. getselfregistrationenabled() indicates whether the current community allows new users to create their own account by filling out a registration form. getselfregistrationurl() returns the location of the self-registration page for new users to sign up for an account with a community. getstarturl() returns the start page of an experience cloud site or salesforce my domain subdomain. this url is the first page that users see when they log in. getusernamepasswordenabled() indicates whether the current community is set to display a login form asking for a username and password. you can configure the community not to request a username and password if it is for unauthenticated users or users logging in with a third-party authentication provider. iscommunityusingsiteascontainer() returns true if the experience cloud site uses site.com pages; otherwise, returns false. getallowinternaluserloginenabled() indicates whether the experience cloud site allows internal users to log in using the experience cloud site login page. to enable, admins configure the setting allow internal users to log in directly to the experience on the login & registration page in experience workspaces. it’s disabled by default. signature public boolean getallowinternaluserloginenabled() return value type: boolean usage if true, internal users log in to an experience cloud site from the site’s login page with their internal credentials. if they navigate to their internal org from the experience cloud site, they don't have to log in again. getauthconfig() returns the authconfig sobject, which represents the authentication options for an experience cloud site or salesforce my domain subdomain. signature public authconfig getauthconfig() 66apex reference guide authconfiguration class return value type: authconfig the authconfig sobject for the experience cloud site or salesforce my domain subdomain. getauthconfigproviders() returns the list of authentication providers configured for an experience cloud site or salesforce my domain subdomain. signature public list<authconfigproviders> getauthconfigproviders() return value type: list<authconfigproviders> a list of authentication providers (authconfigproviders sobjects), which are children of the authprovider sobject. getauthproviders() returns the list of authentication providers available for an experience cloud site or salesforce my domain subdomain. signature public list<authprovider> getauthproviders() return value type: list<authprovider> a list of authentication providers (authprovider sobject
s) for the experience cloud site or my domain subdomain. getauthproviderssodomainurl(communityurl, starturl, developername) returns the single sign-on url for an experience cloud site subdomain. note: for better performance, we recommend using this method instead of getauthproviderssourl. if the authentication provider has user subdomain for callback enabled, changing the single sign-on url also changes the callback url to use the experience cloud site subdomain. before switching to this method, update the callback url in your third-party applications to avoid getting an invalid callback url error during single sign-on. signature public static string getauthproviderssodomainurl(string communityurl, string starturl, string developername) parameters communityurl type: string 67apex reference guide authconfiguration class the url for the experience cloud site subdomain. if null or specified as an empty string, you get the single sign-on url for the org’s my domain. starturl type: string the page that users see after logging in to the experience cloud site subdomain. developername type: string the unique name of the authentication provider. return value type: string the single sign-on initialization url for the experience cloud site subdomain. getauthproviderssourl(communityurl, starturl, developername) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. signature public static string getauthproviderssourl(string communityurl, string starturl, string developername) parameters communityurl type: string the url for the experience cloud site or my domain subdomain. if not null and not specified as an empty string, you get the url for the experience cloud site. if null or specified as an empty string, you get the url for a custom domain. starturl type: string the page that users see after logging in to the experience cloud site or my domain subdomain. developername type: string the unique name of the authentication provider. return value type: string the single sign-on initialization url for the experience cloud site or salesforce my domain subdomain. getbackgroundcolor() returns the color for the background of the login page for a community. 68apex reference guide authconfiguration class signature public string getbackgroundcolor() return value type: string getcertificateloginenabled(domainurl) returns true if certificate-based authentication is enabled for the my domain url. signature public boolean getcertificateloginenabled(string domainurl) parameters domainurl type: string the my domain url that is being checked for certificate-based authentication. return value type: boolean getcertificateloginurl(domainurl, starturl) returns the certificate-based authentication endpoint for the my domain url if the org has certificate-based authentication enabled. signature public static string getcertificateloginurl(string domainurl, string starturl) parameters domainurl type: string the my domain url being checked for its certificate-based authentication endpoint . starturl type: string the page that the user is directed to after logging in to the my domain with certificate-based authentication. return value type: string the certificate-based authentication endpoint for the my domain url: mydomainurl:8443/services/certauth?starturl=starturlparam 69apex reference guide authconfiguration class getdefaultprofileforregistration() returns the profile id assigned to new community users. signature public string getdefaultprofileforregistration() return value type: string the profile id. getfootertext() returns the text at the bottom of the login page for a community. signature public string getfootertext() return value type: string the text string displayed at the bottom of the login page, for example “log in with an existing account.” getforgotpasswordurl() returns the url for the standard or custom forgot password page that is specified for an experience cloud site or portal by the administrator. signature public string getforgotpasswordurl() return value type: string url for the standard or custom forgot password page. getheadlessforgotpasswordenabled() returns true if the headless forgot password flow is enabled. signature public boolean getheadlessforgotpasswordenabled() 70apex reference guide authconfiguration class return value type: boolean getheadlessfrgtpswenabled() this method will be deprecated in a future release. use the getheadlessforgotpasswordenabled() method in
this class instead. signature public boolean getheadlessfrgtpswenabled() return value type: boolean getheadlessregistrationenabled() determines if the headless registration flow is enabled. signature public boolean getheadlessregistrationenabled() return value type: boolean returns true if headless registration is enabled. getlogourl() returns the location of the icon image at the bottom of the login page for a community. signature public string getlogourl() return value type: string the path to the icon image. getrightframeurl() returns the url for the right-frame content to display on the right side of the experience cloud site login page. the admin supplies the url. signature public string getloginrightframeurl() 71apex reference guide authconfiguration class return value type: string url for the right-frame content of the experience cloud site login page. salesforce creates an inline (iframe) on the right side of the login page to display the contents specified by the url. getsamlproviders() returns the list of saml-based authentication providers available for an experience cloud site or salesforce my domain subdomain. signature public list<samlssoconfig> getsamlproviders() return value type: list<samlssoconfig> a list of saml-based authentication providers, which are samlssoconfig sobjects. getsamlssourl(communityurl, starturl, samlid) returns the single sign-on url for an experience cloud site or salesforce my domain subdomain. signature public static string getsamlssourl(string communityurl, string starturl, string samlid) parameters communityurl type: string the url for the experience cloud site or my domain subdomain. if not null and not specified as an empty string, you get the url for the experience cloud site. if null or specified as an empty string, you get the url for a my domain subdomain. starturl type: string the page users see after successfully logging in to the experience cloud site or my domain subdomain samlid type: string the unique identifier of the samlssoconfig standard object for the experience cloud site or my domain subdomain return value type: string the single sign-on initialization url for the experience cloud site or salesforce my domain subdomain. getselfregistrationenabled() indicates whether the current community allows new users to create their own account by filling out a registration form. 72apex reference guide authconfiguration class signature public boolean getselfregistrationenabled() return value type: boolean getselfregistrationurl() returns the location of the self-registration page for new users to sign up for an account with a community. signature public string getselfregistrationurl() return value type: string the location of the self-registration page. getstarturl() returns the start page of an experience cloud site or salesforce my domain subdomain. this url is the first page that users see when they log in. signature public string getstarturl() return value type: string the location of the start page for the experience cloud site or my domain subdomain. getusernamepasswordenabled() indicates whether the current community is set to display a login form asking for a username and password. you can configure the community not to request a username and password if it is for unauthenticated users or users logging in with a third-party authentication provider. signature public boolean getusernamepasswordenabled() return value type: boolean 73apex reference guide authprovidercallbackstate class iscommunityusingsiteascontainer() returns true if the experience cloud site uses site.com pages; otherwise, returns false. signature public boolean iscommunityusingsiteascontainer() return value type: boolean authprovidercallbackstate class provides request http headers, body, and query parameters to the authproviderplugin.handlecallback method for user authentication. this class allows you to group the information passed in rather than passing headers, body, and query parameters individually. namespace auth in this section: authprovidercallbackstate constructors authprovidercallbackstate properties see also: handlecallback(authproviderconfiguration, callbackstate) authprovidercallbackstate constructors the following are constructors for authprovidercallbackstate. in this section: authprovidercallbackstate(headers, body, queryparameters) creates an instance of the authprovidercallbackstate class using the specified http headers, body, and query parameters of the authentication request
. authprovidercallbackstate(headers, body, queryparameters) creates an instance of the authprovidercallbackstate class using the specified http headers, body, and query parameters of the authentication request. signature public authprovidercallbackstate(map<string,string> headers, string body, map<string,string> queryparameters) 74apex reference guide authprovidercallbackstate class parameters headers type: map<string,string> the http headers of the authentication request. body type: string the http body of the authentication request. queryparameters type: map<string,string> the http query parameters of the authentication request. authprovidercallbackstate properties the following are properties for authprovidercallbackstate. in this section: body the http body of the authentication request. headers the http headers of the authentication request. queryparameters the http query parameters of the authentication request. body the http body of the authentication request. signature public string body {get; set;} property value type: string headers the http headers of the authentication request. signature public map<string,string> headers {get; set;} property value type: map<string,string> 75apex reference guide authproviderplugin interface queryparameters the http query parameters of the authentication request. signature public map<string,string> queryparameters {get; set;} property value type: map<string,string> authproviderplugin interface this interface is deprecated. for new development, use the abstract class auth.authproviderpluginclass to create a custom oauth-based authentication provider plug-in for single sign-on in to salesforce. namespace auth usage deprecated. existing implementations that use auth.authproviderplugin still work. for new development, use auth.authproviderpluginclass. in this section: authproviderplugin methods authproviderplugin example implementation authproviderplugin methods the following methods are for authproviderplugin, which, as of api version 39.0, is deprecated. use themethods in authproviderpluginclass instead. in this section: getcustommetadatatype() deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. getuserinfo(authproviderconfiguration, response) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. handlecallback(authproviderconfiguration, callbackstate) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. 76apex reference guide authproviderplugin interface initiate(authproviderconfiguration, statetopropagate) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. see also: salesforce help: create a custom external authentication provider getcustommetadatatype() deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. signature public string getcustommetadatatype() return value type: string the custom metadata type api name for the authentication provider. usage returns the custom metadata type api name for a custom oauth-based authentication provider for single sign-on to salesforce. the getcustommetatadatype() method returns only custom metadata type names. it does not return custom metadata record names. getuserinfo(authproviderconfiguration, response) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. signature public auth.userdata getuserinfo(map<string,string> authproviderconfiguration, auth.authprovidertokenresponse response) parameters authproviderconfiguration type: map<string,string> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. response type: auth.authprovidertokenresponse the oauth access token, oauth secret or refresh token, and state provided by the authentication provider to authenticate the current user. 77apex reference guide authproviderplugin interface return value type: auth.userdata creates a new instance of the auth.userdata class. usage returns information from the custom authentication provider about the current user. the registration handler and other authentication provider flows use this information. handlecallback(authproviderconfiguration, callbackstate) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass.
signature public auth.authprovidertokenresponse handlecallback(map<string,string> authproviderconfiguration, auth.authprovidercallbackstate callbackstate) parameters authproviderconfiguration type: map<stringstring> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. callbackstate type: auth.authprovidercallbackstate the class that contains the http headers, body, and queryparams of the authentication request. return value type: auth.authprovidertokenresponse creates an instance of the authprovidertokenresponse class. usage uses the authentication provider’s supported authentication protocol to return an oauth access token, oauth secret or refresh token, and the state passed in when the request for the current user was initiated. initiate(authproviderconfiguration, statetopropagate) deprecated as of api version 39.0. use the corresponding method in auth.authproviderpluginclass. signature public system.pagereference initiate(map<string,string> authproviderconfiguration, string statetopropagate) 78apex reference guide authproviderpluginclass class parameters authproviderconfiguration type: map<stringstring> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. statetopropagate type: string the state passed in to initiate the authentication request for the user. return value type: system.pagereference the url of the page where the user is redirected for authentication. usage returns the url where the user is redirected for authentication. authproviderplugin example implementation we’ve removed the example implementation for the auth.authproviderplugin interface because we’ve deprecated the interface and replaced it with an abstract class. see authproviderpluginclass class. authproviderpluginclass class contains methods to create a custom oauth-based authentication provider plug-in for single sign-on in to salesforce. use this class to create a custom authentication provider plug-in if you can’t use one of the authentication providers that salesforce provides. namespace auth usage to create a custom authentication provider for single sign-on, create a class that extends auth.authproviderpluginclass. this class allows you to store the custom configuration for your authentication provider and handle authentication protocols when users log in to salesforce with their login credentials for an external service provider. in salesforce, the class that implements this interface appears in the provider type drop-down list in auth. providers in setup. make sure that the user you specify to run the class has “customize application” and “manage auth. providers” permissions. as of api version 39.0, use the abstract class authproviderpluginclass to create a custom external authentication provider. this class replaces the authproviderplugin interface. if you’ve already implemented a custom authentication provider plug-in using the interface, it still works. however, use authproviderpluginclass to extend your plug-in. if you haven’t created an interface, create a custom authentication provider plug-in by extending this abstract class. for more information, see authproviderpluginclass code example. 79apex reference guide authproviderpluginclass class in this section: authproviderpluginclass methods authproviderpluginclass code example authproviderpluginclass methods the authproviderpluginclass methods don’t support dml options. in this section: getcustommetadatatype() returns the custom metadata type api name for a custom oauth-based authentication provider for single sign-on to salesforce. getuserinfo(authproviderconfiguration, response) returns information from the custom authentication provider about the current user. this information is used by the registration handler and in other authentication provider flows. handlecallback(authproviderconfiguration, callbackstate) uses the authentication provider’s supported authentication protocol to return an oauth access token, oauth secret or refresh token, and the state passed in when the request for the current user was initiated. initiate(authproviderconfiguration, statetopropagate) returns the url where the user is redirected for authentication. refresh(authproviderconfiguration, refreshtoken) returns a new access token, which is used to update an expired access token. getcustommetadatatype() returns the custom metadata type api name for a custom oauth
-based authentication provider for single sign-on to salesforce. signature public string getcustommetadatatype() return value type: string the custom metadata type api name for the authentication provider. usage the getcustommetatadatype() method returns only custom metadata type names. it does not return custom metadata record names. as of api version 39.0, use this method when extending auth.authproviderpluginclass to create a custom external authentication provider. getuserinfo(authproviderconfiguration, response) returns information from the custom authentication provider about the current user. this information is used by the registration handler and in other authentication provider flows. 80apex reference guide authproviderpluginclass class signature public auth.userdata getuserinfo(map<string,string> authproviderconfiguration, auth.authprovidertokenresponse response) parameters authproviderconfiguration type: map<string,string> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates it with the custom metadata type default values. or you can set the configuration with values that you enter when you create the custom provider in auth. providers in setup. response type: auth.authprovidertokenresponse the oauth access token, oauth secret or refresh token, and state provided by the authentication provider to authenticate the current user. return value type: auth.userdata creates a new instance of the auth.userdata class. usage as of api version 39.0, use this method when extending auth.authproviderpluginclass to create a custom authentication provider. note: you might choose to get user information in the response from the handlecallback method or by another method. however, you must still call getuserinfo in the custom authentication handler to avoid getting errors about mixing objects. for example, if you don’t call getuserinfo, and then try to insert a contact in the auth.registrationhandler.createuser method, you get the error, “you cannot mix entityobjects with different uddinfos within one transaction.” to avoid this error, call getuserinfo with dummy user information as follows. httprequest req = new httprequest(); string url = 'https://login.salesforce.com/'; req.setendpoint(url); req.setmethod('get'); http http = new http(); httpresponse res = http.send(req); handlecallback(authproviderconfiguration, callbackstate) uses the authentication provider’s supported authentication protocol to return an oauth access token, oauth secret or refresh token, and the state passed in when the request for the current user was initiated. signature public auth.authprovidertokenresponse handlecallback(map<string,string> authproviderconfiguration, auth.authprovidercallbackstate callbackstate) 81apex reference guide authproviderpluginclass class parameters authproviderconfiguration type: map<stringstring> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. callbackstate type: auth.authprovidercallbackstate the class that contains the http headers, body, and queryparams of the authentication request. return value type: auth.authprovidertokenresponse creates an instance of the authprovidertokenresponse class. usage as of api version 39.0, use this method when extending auth.authproviderpluginclass to create a custom authentication provider. initiate(authproviderconfiguration, statetopropagate) returns the url where the user is redirected for authentication. signature public system.pagereference initiate(map<string,string> authproviderconfiguration, string statetopropagate) parameters authproviderconfiguration type: map<stringstring> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. statetopropagate type: string the state passed in to initiate the authentication request for the user. return value type: system.pagereference the url of the page where the user is redirected for authentication. 82
apex reference guide authproviderpluginclass class usage as of api version 39.0, use this method when extending auth.authproviderpluginclass to create a custom authentication provider. refresh(authproviderconfiguration, refreshtoken) returns a new access token, which is used to update an expired access token. signature public auth.oauthrefreshresult refresh(map<string,string> authproviderconfiguration, string refreshtoken) parameters authproviderconfiguration type: map<string,string> the configuration for the custom authentication provider. when you create a custom metadata type in salesforce, the configuration populates with the custom metadata type default values. or you can set the configuration with values you enter when you create the custom provider in auth. providers in setup. refreshtoken type: string the refresh token for the user who is logged in. return value type: auth.oauthrefreshresult returns the new access token, or an error message if an error occurs. usage a successful request returns a auth.oauthrefreshresult with the access token and refresh token in the response. if you receive an error, make sure that you set the error string to the error message. a null error string indicates no error. the refresh method works only with named credentials; it doesn’t respect the standard oauth refresh flow. the refresh method with named credentials works only if the earlier request returns a 401. authproviderpluginclass code example the following example demonstrates how to implement a custom auth. provider plug-in using the abstract class, auth.authproviderpluginclass. global class concur extends auth.authproviderpluginclass { // use this url for the endpoint that the // authentication provider calls back to for configuration. public string redirecturl; private string key; private string secret; 83apex reference guide authproviderpluginclass class // application redirection to the concur website for // authentication and authorization. private string authurl; // uri to get the new access token from concur using the get verb. private string accesstokenurl; // api name for the custom metadata type created for this auth provider. private string custommetadatatypeapiname; // api url to access the user in concur private string userapiurl; // version of the user api url to access data from concur private string userapiversionurl; global string getcustommetadatatype() { return custommetadatatypeapiname; } global pagereference initiate(map<string,string> authproviderconfiguration, string statetopropagate) { authurl = authproviderconfiguration.get('auth_url__c'); key = authproviderconfiguration.get('key__c'); // here the developer can build up a request of some sort. // ultimately, they return a url where we will redirect the user. string url = authurl + '?client_id='+ key +'&scope=user,exprpt,list&redirect_uri='+ redirecturl + '&state=' + statetopropagate; return new pagereference(url); } global auth.authprovidertokenresponse handlecallback(map<string,string> authproviderconfiguration, auth.authprovidercallbackstate state ) { // here, the developer will get the callback with actual protocol. // their responsibility is to return a new object called // authprovidertokenresponse. // this will contain an optional accesstoken and refreshtoken key = authproviderconfiguration.get('key__c'); secret = authproviderconfiguration.get('secret__c'); accesstokenurl = authproviderconfiguration.get('access_token_url__c'); map<string,string> queryparams = state.queryparameters; string code = queryparams.get('code'); string sfdcstate = queryparams.get('state'); httprequest req = new httprequest(); string url = accesstokenurl+'?code=' + code + '&client_id=' + key + '&client_secret=' + secret; req.setendpoint(url); req.setheader('content-type','application/xml'); 84apex reference guide authproviderpluginclass class req.setmethod('get'); http http = new http(); httpresponse res = http.send(req); string responsebody = res.getbody(); string token = gettokenvaluefromresponse(responsebody, 'token', null); return new auth.authprovidertokenresponse('concur', token, 'refreshtoken', sfdcstate); } global auth.userdata getuserinfo(
map<string,string> authproviderconfiguration, auth.authprovidertokenresponse response) { //here the developer is responsible for constructing an //auth.userdata object string token = response.oauthtoken; httprequest req = new httprequest(); userapiurl = authproviderconfiguration.get('api_user_url__c'); userapiversionurl = authproviderconfiguration.get ('api_user_version_url__c'); req.setheader('authorization', 'oauth ' + token); req.setendpoint(userapiurl); req.setheader('content-type','application/xml'); req.setmethod('get'); http http = new http(); httpresponse res = http.send(req); string responsebody = res.getbody(); string id = gettokenvaluefromresponse(responsebody, 'loginid',userapiversionurl); string fname = gettokenvaluefromresponse(responsebody, 'firstname', userapiversionurl); string lname = gettokenvaluefromresponse(responsebody, 'lastname', userapiversionurl); string flname = fname + ' ' + lname; string uname = gettokenvaluefromresponse(responsebody, 'emailaddress', userapiversionurl); string locale = gettokenvaluefromresponse(responsebody, 'localename', userapiversionurl); map<string,string> provmap = new map<string,string>(); provmap.put('what1', 'noidea1'); provmap.put('what2', 'noidea2'); return new auth.userdata(id, fname, lname, flname, uname, 'what', locale, null, 'concur', null, provmap); } private string gettokenvaluefromresponse(string response, string token, string ns) { dom.document docx = new dom.document(); docx.load(response); string ret = null; 85apex reference guide authproviderpluginclass class dom.xmlnode xroot = docx.getrootelement() ; if(xroot != null){ ret = xroot.getchildelement(token, ns).gettext(); } return ret; } } sample test classes the following example contains test classes for the concur class. @istest public class concurtestclass { private static final string oauth_token = 'testtoken'; private static final string state = 'mockteststate'; private static final string refresh_token = 'refreshtoken'; private static final string login_id = 'testloginid'; private static final string username = 'testusername'; private static final string first_name = 'testfirstname'; private static final string last_name = 'testlastname'; private static final string email_address = 'testemailaddress'; private static final string locale_name = 'testlocalname'; private static final string full_name = first_name + ' ' + last_name; private static final string provider = 'concur'; private static final string redirect_url = 'http://localhost/services/authcallback/orgid/concur'; private static final string key = 'testkey'; private static final string secret = 'testsecret'; private static final string state_to_propogate = 'teststate'; private static final string access_token_url = 'http://www.dummyhost.com/accesstokenuri'; private static final string api_user_version_url = 'http://www.dummyhost.com/user/20/1'; private static final string auth_url = 'http://www.dummy.com/authurl'; private static final string api_user_url = 'www.concursolutions.com/user/api'; // in the real world scenario, the key and value would be read // from the (custom fields in) custom metadata type record. private static map<string,string> setupauthproviderconfig () { map<string,string> authproviderconfiguration = new map<string,string>(); authproviderconfiguration.put('key__c', key); authproviderconfiguration.put('auth_url__c', auth_url); authproviderconfiguration.put('secret__c', secret); authproviderconfiguration.put('access_token_url__c', access_token
_url); authproviderconfiguration.put('api_user_url__c',api_user_url); authproviderconfiguration.put('api_user_version_url__c', 86apex reference guide authproviderpluginclass class api_user_version_url); authproviderconfiguration.put('redirect_url__c',redirect_url); return authproviderconfiguration; } static testmethod void testinitiatemethod() { string statetopropogate = 'mockteststate'; map<string,string> authproviderconfiguration = setupauthproviderconfig(); concur concurcls = new concur(); concurcls.redirecturl = authproviderconfiguration.get('redirect_url__c'); pagereference expectedurl = new pagereference(authproviderconfiguration.get('auth_url__c') + '?client_id='+ authproviderconfiguration.get('key__c') +'&scope=user,exprpt,list&redirect_uri='+ authproviderconfiguration.get('redirect_url__c') + '&state=' + state_to_propogate); pagereference actualurl = concurcls.initiate(authproviderconfiguration, state_to_propogate); system.assertequals(expectedurl.geturl(), actualurl.geturl()); } static testmethod void testhandlecallback() { map<string,string> authproviderconfiguration = setupauthproviderconfig(); concur concurcls = new concur(); concurcls.redirecturl = authproviderconfiguration.get ('redirect_url_c'); test.setmock(httpcalloutmock.class, new concurmockhttpresponsegenerator()); map<string,string> queryparams = new map<string,string>(); queryparams.put('code','code'); queryparams.put('state',authproviderconfiguration.get('state_c')); auth.authprovidercallbackstate cbstate = new auth.authprovidercallbackstate(null,null,queryparams); auth.authprovidertokenresponse actualauthprovresponse = concurcls.handlecallback(authproviderconfiguration, cbstate); auth.authprovidertokenresponse expectedauthprovresponse = new auth.authprovidertokenresponse( 'concur', oauth_token, refresh_token, null); system.assertequals(expectedauthprovresponse.provider, actualauthprovresponse.provider); system.assertequals(expectedauthprovresponse.oauthtoken, actualauthprovresponse.oauthtoken); system.assertequals(expectedauthprovresponse.oauthsecretorrefreshtoken, actualauthprovresponse.oauthsecretorrefreshtoken); system.assertequals(expectedauthprovresponse.state, 87apex reference guide authproviderpluginclass class actualauthprovresponse.state); } static testmethod void testgetuserinfo() { map<string,string> authproviderconfiguration = setupauthproviderconfig(); concur concurcls = new concur(); test.setmock(httpcalloutmock.class, new concurmockhttpresponsegenerator()); auth.authprovidertokenresponse response = new auth.authprovidertokenresponse( provider, oauth_token ,'sampleoauthsecret', state); auth.userdata actualuserdata = concurcls.getuserinfo( authproviderconfiguration, response) ; map<string,string> provmap = new map<string,string>(); provmap.put('key1', 'value1'); provmap.put('key2', 'value2'); auth.userdata expecteduserdata = new auth.userdata(login_id, first_name, last_name, full_name, email_address, null, locale_name, null, provider, null, provmap); system.assertnotequals(expecteduserdata,null); system.assertequals(expecteduserdata.firstname, actualuserdata.firstname); system.assertequals(expecteduserdata.lastname, actualuserdata.lastname); system.assertequals(expecteduserdata.fullname, actualuserdata.fullname); system.assertequals(expecteduserdata.email, actualuserdata.email); system.assertequals(expecteduserdata.username, actualuserdata.username); system.assert
equals(expecteduserdata.locale, actualuserdata.locale); system.assertequals(expecteduserdata.provider, actualuserdata.provider); system.assertequals(expecteduserdata.siteloginurl, actualuserdata.siteloginurl); } // implement a mock http response generator for concur. public class concurmockhttpresponsegenerator implements httpcalloutmock { public httpresponse respond(httprequest req) { string namespace = api_user_version_url; string prefix = 'mockprefix'; 88apex reference guide authprovidertokenresponse class dom.document doc = new dom.document(); dom.xmlnode xmlnode = doc.createrootelement( 'mockrootnodename', namespace, prefix); xmlnode.addchildelement('loginid', namespace, prefix) .addtextnode(login_id); xmlnode.addchildelement('firstname', namespace, prefix) .addtextnode(first_name); xmlnode.addchildelement('lastname', namespace, prefix) .addtextnode(last_name); xmlnode.addchildelement('emailaddress', namespace, prefix) .addtextnode(email_address); xmlnode.addchildelement('localename', namespace, prefix) .addtextnode(locale_name); xmlnode.addchildelement('token', null, null) .addtextnode(oauth_token); system.debug(doc.toxmlstring()); // create a fake response httpresponse res = new httpresponse(); res.setheader('content-type', 'application/xml'); res.setbody(doc.toxmlstring()); res.setstatuscode(200); return res; } } } authprovidertokenresponse class stores the response from the authproviderplugin.handlecallback method. namespace auth in this section: authprovidertokenresponse constructors authprovidertokenresponse properties authprovidertokenresponse constructors the following are constructors for authprovidertokenresponse. in this section: authprovidertokenresponse(provider, oauthtoken, oauthsecretorrefreshtoken, state) creates an instance of the authprovidertokenresponse class using the specified authentication provider, oauth access token, oauth secret or refresh token, and state for a custom authentication provider plug-in. 89apex reference guide authprovidertokenresponse class authprovidertokenresponse(provider, oauthtoken, oauthsecretorrefreshtoken, state) creates an instance of the authprovidertokenresponse class using the specified authentication provider, oauth access token, oauth secret or refresh token, and state for a custom authentication provider plug-in. signature public authprovidertokenresponse(string provider, string oauthtoken, string oauthsecretorrefreshtoken, string state) parameters provider type: string the custom authentication provider. oauthtoken type: string the oauth access token. oauthsecretorrefreshtoken type: string the oauth secret or refresh token for the currently logged-in user. state type: string the state passed in to initiate the authentication request for the user. authprovidertokenresponse properties the following are properties for authprovidertokenresponse. in this section: oauthsecretorrefreshtoken the oauth secret or refresh token for the currently logged-in user. oauthtoken the oauth access token. provider the authentication provider. state the state passed in to initiate the authentication request for the user. oauthsecretorrefreshtoken the oauth secret or refresh token for the currently logged-in user. 90apex reference guide authtoken class signature public string oauthsecretorrefreshtoken {get; set;} property value type: string oauthtoken the oauth access token. signature public string oauthtoken {get; set;} property value type: string provider the authentication provider. signature public string provider {get; set;} property value type: string state the state passed in to initiate the authentication request for the user. signature public string state {get; set;} property value type: string authtoken class contains methods for providing the access token associated with an authentication provider for an authenticated user, except for the janrain provider. 91apex reference guide authtoken class namespace auth authtoken methods the following are methods for
authtoken. all methods are static. in this section: getaccesstoken(authproviderid, providername) returns an access token for the current user using the specified 18-character identifier of an authprovider definition in your org and the proper name of the third party, such as salesforce or facebook. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. getaccesstokenmap(authproviderid, providername) returns a map from the third-party identifier to the access token for the currently logged-in salesforce user. the identifier value depends on the third party. for example, for salesforce it would be the user id, while for facebook it would be the user number. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. refreshaccesstoken(authproviderid, providername, oldaccesstoken) returns a map from the third-party identifier containing a refreshed access token for the currently logged-in salesforce user. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. revokeaccess(authproviderid, providername, userid, remoteidentifier) revokes the access token for a specified social sign-on user from a third-party service such as facebook©. you can use this method only if the isnotssousable field on the associated thirdpartyaccountlink object is set to false. querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. getaccesstoken(authproviderid, providername) returns an access token for the current user using the specified 18-character identifier of an authprovider definition in your org and the proper name of the third party, such as salesforce or facebook. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. signature public static string getaccesstoken(string authproviderid, string providername) 92apex reference guide authtoken class parameters authproviderid type: string providername type: string the proper name of the third party. for all providers except janrain, the expected values are • facebook • salesforce • open id connect • microsoft access control service • linkedin • twitter • google for janrain providers, the parameter value is the proper name of the third party used. yahoo! is an example of a janrain provider value. return value type: string getaccesstokenmap(authproviderid, providername) returns a map from the third-party identifier to the access token for the currently logged-in salesforce user. the identifier value depends on the third party. for example, for salesforce it would be the user id, while for facebook it would be the user number. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. signature public static map<string, string> getaccesstokenmap(string authproviderid, string providername) parameters authproviderid type: string providername type: string the proper name of the third party. for all providers except janrain, the expected values are • facebook • salesforce • open id connect • microsoft access control service 93apex reference guide authtoken class • linkedin • twitter • google for janrain providers, the parameter value is the proper name of the third party used. yahoo! is an example of a janrain provider value. return value type: map<
string, string> refreshaccesstoken(authproviderid, providername, oldaccesstoken) returns a map from the third-party identifier containing a refreshed access token for the currently logged-in salesforce user. note that querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. signature public static map<string, string> refreshaccesstoken(string authproviderid, string providername, string oldaccesstoken) parameters authproviderid type: string providername type: string the proper name of the third party. for all providers except janrain, the expected values are • facebook • salesforce • open id connect • microsoft access control service • linkedin • twitter • google for janrain providers, the parameter value is the proper name of the third party used. yahoo! is an example of a janrain provider value. oldaccesstoken type: string return value type: map<string, string> 94apex reference guide authtoken class usage this method works when using salesforce or an openid connect provider, but not when using facebook or janrain. the returned map contains accesstoken and refresherror keys. evaluate the keys in the response to check if the request was successful. for a successful request, the refresherror value is null, and accesstoken is a token value. for an unsuccessful request, the refresherror value is an error message, and the accesstoken value is null. when successful, this method updates the token stored in the database, which you can get using auth.authtoken.getaccesstoken(). if you are using an openid connect authentication provider, an id_token is not required in the response from the provider. if a token issuer is specified in the auth. provider settings and an id_token is provided anyway, salesforce will verify it. example string accesstoken = auth.authtoken.getaccesstoken('0sod000000000deoai', 'open id connect'); map<string, string> responsemap = auth.authtoken.refreshaccesstoken('0sod000000000deoai', 'open id connect', accesstoken); a successful request includes the access token in the response. (refresherror,null)(accesstoken,00dd00000007bhe!aqkaqfzj...) revokeaccess(authproviderid, providername, userid, remoteidentifier) revokes the access token for a specified social sign-on user from a third-party service such as facebook©. you can use this method only if the isnotssousable field on the associated thirdpartyaccountlink object is set to false. querying the providertype field on the authprovider object sometimes returns a value that differs from the expected provider name value. for example, for open id connect providers, openidconnect is the providertype value for the authprovider object, but the expected providername is open id connect. signature public static boolean revokeaccess(string authproviderid, string providername, string userid, string remoteidentifier) parameters authproviderid type: string the id of the auth. provider in the salesforce organization. providername type: string the proper name of the third party. for all providers except janrain, the expected values are • facebook • salesforce • open id connect • microsoft access control service • linkedin • twitter 95apex reference guide communitiesutil class • google for janrain providers, the parameter value is the proper name of the third party used. yahoo! is an example of a janrain provider value. userid type: string the 15-character id for the user whose access is being revoked. remoteidentifier type: string the unique id for the user in the third-party system (this value is in the associated thirdpartyaccountlink standard object). return value type: boolean the return value is true if the revokeaccess() operation is successful; otherwise false. example the following example revokes a facebook user's access token. auth.authtoken.revokeaccess('0soxx00000#####', 'facebook', '005xx00000#####', 'thirdpartyidentifier_exist214176560#####'); communitiesutil class contains methods for getting information about an experience cloud user. namespace auth example the following example directs a guest (unauthenticated) user to one page,
and authenticated users of the experience cloud site’s parent organization to another page. if (auth.communitiesutil.isguestuser()) // redirect to the login page if user is an unauthenticated user return new pagereference(login_url); if (auth.communitiesutil.isinternaluser()) // redirect to the home page if user is an internal user return new pagereference(home_url); communitiesutil methods the following are methods for communitiesutil. all methods are static. 96apex reference guide communitiesutil class in this section: getlogouturl() returns the page to display after the current experience cloud user logs out. getuserdisplayname() returns the current user’s experience cloud display name. isguestuser() indicates whether the current user isn’t logged in to the experience cloud site. redirect the user to log in, if necessary. isinternaluser() indicates whether the current user is logged in as a member of the parent salesforce organization, such as an employee. getlogouturl() returns the page to display after the current experience cloud user logs out. signature public static string getlogouturl() return value type: string getuserdisplayname() returns the current user’s experience cloud display name. signature public static string getuserdisplayname() return value type: string isguestuser() indicates whether the current user isn’t logged in to the experience cloud site. redirect the user to log in, if necessary. signature public static boolean isguestuser() return value type: boolean isinternaluser() indicates whether the current user is logged in as a member of the parent salesforce organization, such as an employee. 97apex reference guide configurableselfreghandler interface signature public static boolean isinternaluser() return value type: boolean configurableselfreghandler interface gives you more control over how customers or partners self-register for your experience cloud site by creating a class that implements auth.configurableselfreghandler. you choose the user information to collect, and how users identify themselves—with their email address, phone number, or another identifier. when verified, you create a customer or partner user and log in the user to your experience cloud site. namespace auth usage you set up site self-registration declaratively on the login & registration (l&r) page of the administration workspace. when combined with a configurable self-registration setup, the handler class can programmatically fill in user fields, including custom fields, and determine how to create a user and log them in. when you select the configurable self-reg page registration page, you choose the user fields to collect from the self-registration form, such as last name, first name, username, nickname, mobile, or email. you also determine the verification method that the user identifies themselves with, which can be email, mobile, or neither. salesforce generates the auth.configurableselfreghandler handler, which contains logic on how to create an experience cloud site member. modify the handler to change how users are created, and how collected user information is used. you can add custom logic to ensure that the email or phone number is unique to the customer or partner who's registering. for example, you can add a custom unique field, and write a copy of the email or phone number to it. you can also change how the user is created. by default, the user is created as a contact associated with the account that you select on the l&r page. the generated configurableselfreghandler is located on the setup apex classes page, and begins with autocreatedconfigselfreg, for example, autocreatedconfigselfreg1532475901849. for an example, see configurableselfreghandler example implementation. for more details, see salesforce customer identity in salesforce help. in this section: configurableselfreghandler method configurableselfreghandler example implementation this apex code implements the auth.configurableselfreghandler interface. after the customer or partner fills out the sign-up page and submits it, the handler is invoked to create an experience cloud member with the supplied information. if the registration process requires email or phone verification, the verification process finishes before the auth.configurableselfreghandler.createuser is invoked. if verification isn’t required, createuser is invoked when the customer or partner submits the page. 98apex reference guide configurableselfreghandler interface configurableselfreghandler method the following is the method for configurableself
reghandler. in this section: createuser(accountid, profileid, registrationattributes, password) create a community member from the information that the visitor provided on your community’s self-registration page. createuser(accountid, profileid, registrationattributes, password) create a community member from the information that the visitor provided on your community’s self-registration page. signature public id createuser(id accountid, id profileid, map<schema.sobjectfield,string> registrationattributes, string password) parameters accountid type: id default account with which the new user is associated. this value comes from the account field setting on login and registration (l&r) page under registration page configuration. profileid type: id profile to assign the new user. this value comes from the profile field setting on the l&r page under registration page configuration. registrationattributes type: map<schema.sobjectfield,string> a map of attributes that the registering user entered on the self-registration page. the fields that appear on the self-registration page come from the user fields selected on the l&r page when the registration type is configurable self-reg page. password type: string the password entered by the user if “include password” is selected on the l&r page. (if a password isn’t entered, the handler must generate one because a password is required to create a user.) return value type: id returns an identifier for the created user object. auth.configurableselfreghandler inserts a user and then returns the id of that user. 99apex reference guide configurableselfreghandler interface configurableselfreghandler example implementation this apex code implements the auth.configurableselfreghandler interface. after the customer or partner fills out the sign-up page and submits it, the handler is invoked to create an experience cloud member with the supplied information. if the registration process requires email or phone verification, the verification process finishes before the auth.configurableselfreghandler.createuser is invoked. if verification isn’t required, createuser is invoked when the customer or partner submits the page. verification occurs by email if the admin chose email as the verification method when setting up the configurable self-reg handler on the login & registration (l&r) page. when a visitor clicks the sign-up link from the login page, salesforce prompts for an email address and then sends a one-time password to the specified email address. if the visitor enters the verification code successfully on the verify page, the user is created and logged in. likewise, if the admin chose text message as the verification method on the l&r page, the visitor is prompted to enter a phone number. salesforce sends a challenge (verification code) via sms to the user. if successful, the user is created and logged in. requiring verification before creating a user reduces the number of dummy users cluttering your org. the auth.configurableselfreghandler class contains logic for generating the user fields required to create a user in case the user doesn’t supply them. the handler generates default values, ensuring that the values are unique by appending a timestamp. you can modify the handler to make sure that the email address and phone number of the customer or partner are also unique. global class autocreatedconfigselfreg implements auth.configurableselfreghandler { private final long current_time = datetime.now().gettime(); private final string[] uppercase_chars = 'abcdefghijklmnopqrstuvwxyz'.split(''); private final string[] lowercase_chars = 'abcdefghijklmnopqrstuvwxyz'.split(''); private final string[] number_chars = '1234567890'.split(''); private final string[] special_chars = '!#$%-_=+<>'.split(''); // this method is called once after verification (if any was configured). // this method should create a user and insert it. // password can be null. // return null or throw an exception to fail creation. global id createuser(id accountid, id profileid, map<sobjectfield, string> registrationattributes, string password) { user u = new user(); u.profileid = profileid; for (sobjectfield field : registrationattributes.keyset()) { string value = registrationattributes.get(field); u.put(field, value); } u = handleunsetrequiredfields(
u); generatecontact(u, accountid); if (string.isblank(password)) { password = generaterandompassword(); } site.validatepassword(u, password, password); if (u.contactid == null) { return site.createexternaluser(u, accountid, password); } u.languagelocalekey = userinfo.getlocale(); u.localesidkey = userinfo.getlocale(); u.emailencodingkey = 'utf-8'; u.timezonesidkey = userinfo.gettimezone().getid(); insert u; system.setpassword(u.id, password); 100apex reference guide configurableselfreghandler interface return u.id; } // method to autogenerate a password if one isn't passed in. // by setting a password for a user, we won't send a // welcome email to set the password. private string generaterandompassword() { string[] characters = new list<string>(uppercase_chars); characters.addall(lowercase_chars); characters.addall(number_chars); characters.addall(special_chars); string newpassword = ''; boolean needsupper = true, needslower = true, needsnumber = true, needsspecial = true; while (newpassword.length() < 50) { integer randomint = generaterandomint(characters.size()); string c = characters[randomint]; if (needsupper && c.isalluppercase()) { needsupper = false; } else if (needslower && c.isalllowercase()) { needslower = false; } else if (needsnumber && c.isnumeric()) { needsnumber = false; } else if (needsspecial && !c.isalphanumeric()) { needsspecial = false; } newpassword += c; } newpassword = addmissingpasswordrequirements(newpassword, needslower, needsupper, needsnumber, needsspecial); return newpassword; } private string addmissingpasswordrequirements(string password, boolean addlowercase, boolean adduppercase, boolean addnumber, boolean addspecial) { if (addlowercase) { password += lowercase_chars[generaterandomint(lowercase_chars.size())]; } if (adduppercase) { password += uppercase_chars[generaterandomint(uppercase_chars.size())]; } if (addnumber) { password += number_chars[generaterandomint(number_chars.size())]; } if (addspecial) { password += special_chars[generaterandomint(special_chars.size())]; } return password; } // generates a random number from 0 up to, but not including, max. private integer generaterandomint(integer max) { return math.mod(math.abs(crypto.getrandominteger()), max); } // loops over required fields that were not passed in to 101apex reference guide confirmuserregistrationhandler interface // set to some default value. private user handleunsetrequiredfields(user u) { if (string.isblank(u.lastname)){ u.lastname = generatelastname(); } if (string.isblank(u.username)) { u.username = generateusername(); } if (string.isblank(u.email)) { u.email = generateemail(); } if (string.isblank(u.alias)) { u.alias = generatealias(); } if (string.isblank(u.communitynickname)) { u.communitynickname = generatecommunitynickname(); } return u; } // method to construct a contact for a user. private void generatecontact(user u, id accountid) { // add logic here if you want to build your own // contact for the use. } // default implementation to try to provide uniqueness. private string generatealias() { string timestring = string.valueof(current_time); return timestring.substring(timestring.length() - 8); } // default implementation to try to provide uniqueness. private string generatelastname() { return 'externaluser' + current_time; }
// default implementation to try to provide uniqueness. private string generateusername() { return 'externaluser' + current_time + '@company.com'; } // default implementation to try to provide uniqueness. private string generateemail() { return 'externaluser' + current_time + '@company.com'; } // default implementation to try to provide uniqueness. private string generatecommunitynickname() { return 'externaluser' + current_time; } } confirmuserregistrationhandler interface manages single sign-on (sso) user mappings between salesforce and a third-party identity provider. use this interface to confirm user mappings before updating them. 102apex reference guide confirmuserregistrationhandler interface namespace auth usage when you set up sso with a third-party identity provider, you create a class that implements a registration handler using the auth.registrationhandler interface. this class manages the process of creating and updating users. for advanced use cases that require you to confirm user information during the update process, implement the auth.confirmuserregistrationhandler interface in your class. this interface must be implemented in addition to auth.registrationhandler. you can use the auth.confirmuserregistrationhandler interface to ensure that users are mapped correctly between salesforce and the third party. when a user who has previously logged in with an authentication provider logs in again, you can confirm that the incoming user data is consistent with the user's third-party identifier. if not, you can identify which user is supposed to be logged in. you can also use the auth.confirmuserregistrationhandler interface to switch context for users with multiple records. for example, a user has two records—an admin user and a standard user. when the user logs in, the third-party identity provider confirms the account used to log in and sends the response to salesforce via the userinfo endpoint. you can then use this information to determine whether to log in the user as an admin or standard user. in this section: confirmuserregistrationhandler methods confirmuserregistrationhandler example implementation confirmuserregistrationhandler methods the following are methods for confirmuserregistrationhandler. in this section: confirmuser(userid, tpalid, portalid, userdata) returns the id of the user to be logged in based on their mapping to a third-party identifier. this method is called before calling the updateuser() method. it's called only if the incoming user has previously logged in and has a third-party account link to a salesforce user. confirmuser(userid, tpalid, portalid, userdata) returns the id of the user to be logged in based on their mapping to a third-party identifier. this method is called before calling the updateuser() method. it's called only if the incoming user has previously logged in and has a third-party account link to a salesforce user. signature public id confirmuser(id userid, id tpalid, id portalid, auth.userdata userdata) 103apex reference guide confirmuserregistrationhandler interface parameters userid type: id the id of the user who is mapped to the third-party identifier via a third-party account link. tpalid type: id the third-party account link corresponding to the third-party identifier. portalid type: id the portal id the user is logging in to. if there's no portal configured, this value can be null. userdata type: auth.userdata contains user information from the third-party identity provider. return value type: id the id of the user to be logged in. if null, login fails. confirmuserregistrationhandler example implementation this example implements the auth.confirmuserregistrationhandler interface during the user update process to confirm that the correct user is logging in based on their email address and last name. global class standarduserregistrationhandler implements auth.registrationhandler, auth.confirmuserregistrationhandler { global user createuser(id portalid, auth.userdata data){ user u = new user(); profile p = [select id from profile where name='standard user']; u.username = data.username + '@salesforce.com'; u.email = data.email; u.lastname = data.lastname; u.firstname = data.firstname; string alias = data.username; if(alias.length() > 8) { alias = alias.substring(0, 8); } u.alias = alias; u.languagelocalekey
= data.attributemap.get('language'); u.localesidkey = data.locale; u.emailencodingkey = 'utf-8'; u.timezonesidkey = 'america/los_angeles'; u.profileid = p.id; return u; } global void updateuser(id userid, id portalid, auth.userdata data) { user u = new user(id=userid); u.username = data.username + '@salesforce.com'; 104apex reference guide connectedappplugin class u.email = data.email; u.lastname = data.lastname; u.firstname = data.firstname; string alias = data.username; if(alias.length() > 8) { alias = alias.substring(0, 8); } u.alias = alias; u.languagelocalekey = data.attributemap.get('language'); u.localesidkey = data.locale; update(u); } global id confirmuser(id userid, id tpalid, id portalid, auth.userdata data) { if (data.email.contains(data.lastname)) { // looks genuine return userid; } else { // find the right user user confirmeduser = [select id from user where email=:data.email]; return confirmeduser.id; } } } the following example tests the implementation: @istest public class standarduserregistrationhandlertest { static testmethod void testconfirmuser() { standarduserregistrationhandler handler = new standarduserregistrationhandler(); auth.userdata sampledata = new auth.userdata('ida', 'firstname', 'a', 'firstname a', 'usera@example.org', null, 'usernamea', 'en_us', 'facebook', null, new map<string, string>{'language' => 'en_us'}); user u = handler.createuser(null, sampledata); insert(u); string uid = u.id; sampledata = new auth.userdata('idb', 'firstname', 'b', 'firstname b', 'usera@example.org', null, 'usernameb', 'en_us', 'facebook', null, new map<string, string>{}); // note that user b is using usera's email id confirmeduserid = handler.confirmuser(uid, '060xx0000004eh6', null, sampledata); system.assertequals(uid, confirmeduserid); // we should see usera's id } } connectedappplugin class contains methods for extending the behavior of a connected app, for example, customizing how a connected app is invoked depending on the protocol used. this class gives you more control over the interaction between salesforce and your connected app. namespace auth 105apex reference guide connectedappplugin class usage when you create a connected app, you specify general information about the app and settings for oauth, web apps, mobile apps, and canvas apps. to customize how the app is invoked, create a connected app handler with this connectedappplugin apex class. for example, use this class to support new authentication protocols or respond to user attributes in a way that benefits a business process. when you create a connected app handler, you also configure the connectedappplugin class to run as an execution user. the execution user authorizes access for the connected app. for example, when you use the authorize method, the execution user authorizes the connected app to access data. if you don't specify an execution user, the plug-in runs as an automated process user, which is a system user that executes tasks behind the scenes. most connectedappplugin methods require that you specify an execution user, with the exception of the customattributes method. for more information, see create a custom connected app handler. example this example authorizes the connected app user to use the connected app if the context is saml and the user has reached the quota tracked in a custom field. it returns the user’s permission set assignments. the example uses auth.invocationcontext to modify a saml assertion before it’s sent to the service provider. global class connectedapppluginexample extends auth.connectedappplugin { // authorize the app if the user has achieved quota tracked in a custom field global override boolean authorize(id userid, id connectedappid, boolean isadminapproved, auth.invocationcontext context
) { // create a custom boolean field hasachievedquota__c on the user record // and then uncomment the block below // user u = [select id, hasachievedquota__c from user where id =: userid].get(0); // return u.hasachievedquota__c; return isadminapproved; } // call a flow during refresh global override void refresh(id userid, id connectedappid, auth.invocationcontext context) { try { map<string, object> inputvariables = new map<string, object>(); inputvariables.put('userid', userid); inputvariables.put('connectedappid', connectedappid); // create a custom trigger ready flow and uncomment the block below // flow.interview.mycustomflow interview = new flow.interview.mycustomflow(inputvariables); // interview.start(); } catch ( exception e ) { system.debug('flow exception:' + e); } } 106apex reference guide connectedappplugin class // return a user’s permission set assignments global override map<string,string> customattributes(id userid, id connectedappid, map<string,string> formuladefinedattributes, auth.invocationcontext context) { list<permissionsetassignment> psas = [select id, permissionset.name from permissionsetassignment where permissionset.isownedbyprofile = false and (assigneeid = :userid)]; string permsets = '['; for (permissionsetassignment psa :psas) { permsets += psa.permissionset.name + ';'; } permsets += ']'; formuladefinedattributes.put('permissionsets', permsets); return formuladefinedattributes; } } in this section: connectedappplugin methods connectedappplugin methods the following are methods for connectedappplugin. in this section: authorize(userid, connectedappid, isadminapproved) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use authorize(userid, connectedappid, isadminapproved, context) instead. authorize(userid, connectedappid, isadminapproved, context) authorizes the specified user to access the connected app. if the connected app is set for users to self-authorize, this method isn’t invoked. customattributes(userid, connectedappid, formuladefinedattributes) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use customattributes(userid, connectedappid, formuladefinedattributes, context) instead. customattributes(userid, connectedappid, formuladefinedattributes, context) sets new attributes for the specified user. when the connected app gets the user’s attributes from the userinfo endpoint or through a saml assertion, use this method to update the attribute values. modifysamlresponse(authsession, connectedappid, samlresponse) modifies the xml generated by the salesforce saml identity provider (idp) before it’s sent to the service provider. refresh(userid, connectedappid) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use refresh(userid, connectedappid, context) instead. refresh(userid, connectedappid, context) salesforce calls this method during a refresh token exchange. 107apex reference guide connectedappplugin class authorize(userid, connectedappid, isadminapproved) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use authorize(userid, connectedappid, isadminapproved, context) instead. signature public boolean authorize(id userid, id connectedappid, boolean isadminapproved) parameters userid type: id the 15-character id of the user attempting to use the connected app. connectedappid type: string the 15-character id of the connected app. isadminapproved type: boolean the approval state of the specified user when the connected app requires approval. return value type: boolean if the connected app requires admin approval, a returned value of true indicates that the current user is approved
. authorize(userid, connectedappid, isadminapproved, context) authorizes the specified user to access the connected app. if the connected app is set for users to self-authorize, this method isn’t invoked. signature public boolean authorize(id userid, id connectedappid, boolean isadminapproved, auth.invocationcontext context) parameters userid type: id the 15-character id of the user attempting to use the connected app. connectedappid type: id the 15-character id of the connected app. isadminapproved type: boolean the approval state of the specified user when the connected app requires approval. 108apex reference guide connectedappplugin class context type: invocationcontext the context in which the connected app is invoked. return value type: boolean if the connected app requires admin approval, a returned value of true indicates that the user is approved. usage connectedappplugin runs on behalf of the current user. but the user must have permission to use the connected app for the plug-in to work. use this method to authorize the user. customattributes(userid, connectedappid, formuladefinedattributes) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use customattributes(userid, connectedappid, formuladefinedattributes, context) instead. signature public map<string,string> customattributes(id userid, id connectedappid, map<string,string> formuladefinedattributes,) parameters userid type: id the 15-character id of the user attempting to use the connected app. connectedappid type: id the 15-character id of the connected app. formuladefinedattributes type: map<string,string> a map of the new set of attributes from the userinfo endpoint (oauth) or from a saml assertion. for more information, see the userinfo endpoint in the online help. return value type: map<string,string> a map of the updated set of attributes. customattributes(userid, connectedappid, formuladefinedattributes, context) sets new attributes for the specified user. when the connected app gets the user’s attributes from the userinfo endpoint or through a saml assertion, use this method to update the attribute values. 109apex reference guide connectedappplugin class signature public map<string,string> customattributes(id userid, id connectedappid, map<string,string> formuladefinedattributes, auth.invocationcontext context) parameters userid type: id the 15-character id of the user attempting to use the connected app. connectedappid type: id the 15-character id for the connected app. formuladefinedattributes type: map<string,string> a map of the current set of attributes from the userinfo endpoint (oauth) or from a saml assertion. for more information, see the userinfo endpoint in the online help. type: invocationcontext the context in which the connected app is invoked. return value type: map<string,string> a map of the updated set of attributes. modifysamlresponse(authsession, connectedappid, samlresponse) modifies the xml generated by the salesforce saml identity provider (idp) before it’s sent to the service provider. signature public dom.xmlnode modifysamlresponse(map<string,string> authsession, id connectedappid, dom.xmlnode samlresponse) parameters authsession type: map<string,string> the attributes for the authorized user’s session. the map includes the 15-character id of the authorized user who’s accessing the connected app. connectedappid type: id the 15-character id of the connected app. samlresponse type: dom.xmlnode contains the saml xml response generated by the idp. 110apex reference guide connectedappplugin class return value type: dom.xmlnode returns an instance of dom.xmlnode containing the modified saml xml response. usage use this method to modify the xml saml response to perform an action based on the context of the saml request before it’s verified, signed, and sent to the target service provider. this method enables developers to extend the connected app plug-in to meet their specific needs. the developer assumes full responsibility for changes made within the connected app plug-
in. the plug-in must include validation and error handling. if the plug-in throws an exception, catch it, log it, and stop the process. don’t send anything to the target service provider. refresh(userid, connectedappid) deprecated and available only in api versions 35.0 and 36.0. as of version 37.0, use refresh(userid, connectedappid, context) instead. signature public void refresh(id userid, id connectedappid) parameters userid type: id the 15-character id of the user requesting the refresh token. connectedappid type: id the 15-character id of the connected app. return value type: void refresh(userid, connectedappid, context) salesforce calls this method during a refresh token exchange. signature public void refresh(id userid, id connectedappid, auth.invocationcontext context) parameters userid type: id the 15-character id of the user requesting the refresh token. 111apex reference guide headlessselfregistrationhandler interface connectedappid type: id the 15-character id of the connected app. context type: invocationcontext the context in which the connected app is invoked. return value type: void headlessselfregistrationhandler interface creates customer and partner users during the headless registration flow. namespace auth usage the headless registration flow allows you to control user registration experience in a third-party app while using salesforce to authenticate users and manage their data access. when you set up this flow, add users in the class that is implementing the auth.headlessselfregistrationhandler interface. this class runs after the user verifies their identity. for a detailed explanation of headless registration, see headless registration flow for private clients or headless registration flow for public clients, depending on your app type. in this section: headlessselfregistrationhandler methods the following are methods for headlessselfregistrationhandler. headlessselfregistrationhandler example implementation this example class implements the auth.headlessselfregistrationhandler interface. the class creates a user based on information that your app sends to headless registration api. it associates the user with the default profile for new users, which you configure in your experience cloud settings. it also creates a contact for the user and assigns it to an account. headlessselfregistrationhandler methods the following are methods for headlessselfregistrationhandler. in this section: createuser(profileid, data, customuserdatamap, experienceid, password) returns a user object using information submitted by your third-party app to headless registration api. 112apex reference guide headlessselfregistrationhandler interface createuser(profileid, data, customuserdatamap, experienceid, password) returns a user object using information submitted by your third-party app to headless registration api. signature public user createuser(id profileid, auth.userdata data, string customuserdatamap, string experienceid, string password) parameters profileid type: id the id of the profile that is assigned to new users. data type: auth.userdata a class that stores information about the user, such as their name and locale. customuserdatamap type: string a string representation of a json object containing custom user information passed in during registration. we recommend that you deserialize this string into the equivalent apex class structure. determine what custom information to collect when you build your app’s registration experience. experienceid type: string the experience cloud site id. password type: string the user password. return value type: user headlessselfregistrationhandler example implementation this example class implements the auth.headlessselfregistrationhandler interface. the class creates a user based on information that your app sends to headless registration api. it associates the user with the default profile for new users, which you configure in your experience cloud settings. it also creates a contact for the user and assigns it to an account. global class exampleheadlessreg implements auth.headlessselfregistrationhandler { global user createuser(id profileid, auth.userdata data, string customuserdatamap, string experienceid, string password){ user u = new user(); u.profileid = profileid; u = handleunsetrequiredfields(u); u.email = data.email; 113apex reference guide invocationcontext enum account a; list<account> accounts = [select id from account where name=:social_account]; if(accounts
.isempty()) { a = new account(name = social_account); insert(a); }else a = accounts[0]; generatecontact(u, a.id); u.languagelocalekey = userinfo.getlocale(); u.localesidkey = userinfo.getlocale(); u.emailencodingkey = 'utf-8'; u.timezonesidkey = userinfo.gettimezone().getid(); return u; } private user handleunsetrequiredfields(user u) { return u; } // method to construct a contact for a user private void generatecontact(user u, id accountid) { // add logic here to build your own contact for the user contact c = new contact(); c.accountid = accountid; c.firstname = u.firstname; c.lastname = u.lastname; insert(c); u.contactid = c.id; } // default implementation to try to provide uniqueness private string generatealias() { string timestring = string.valueof(current_time); return timestring.substring(timestring.length() - 8); } } invocationcontext enum the context in which the connected app is invoked, such as the protocol flow used and the token type issued, if any. developers can use the context information to write code that is unique to the type of invocation. enum values the following are the values of the auth.invocationcontext enum. value description asset_token reserved for future use. 114apex reference guide jws class value description oauth1 context used when authentication is through an oauth 1.0a flow. oauth2_jwt_bearer_token context used when authentication is through a json-based web token (jwt) bearer token flow. oauth2_saml_assertion context used when authentication is through an oauth 2.0 saml assertion flow. oauth2_saml_bearer_assertion context used when authentication is through an oauth 2.0 saml bearer assertion flow. oauth2_username_password context used when authentication is through an oauth 2.0 username-password flow. oauth2_user_agent_id_token context used when issuing an id token through an oauth 2.0 user-agent flow. oauth2_user_agent_token context used when authentication is through an oauth 2.0 user agent flow. oauth2_web_server context used when authentication is through a web server authentication flow. openidconnect context used when authentication is through an openid connect authentication flow. refresh_token context used when renewing tokens issued by a web server or user-agent flow. saml_assertion context used when authentication is through a saml assertion flow. unknown context is unknown. userid_endpoint context used when issuing an access token through a userinfo endpoint. see also: salesforce help: authenticating apps with oauth jws class contains methods that apply a digital signature to a json web token (jwt), using a json web signature (jws) data structure. this class creates the signed jwt bearer token, which can be used to request an oauth access token in the oauth 2.0 jwt bearer token flow. namespace auth usage use the methods in this class to sign the jwt bearer token with the x509 certificate. in this section: jws constructors jws methods 115apex reference guide jws class jws constructors the following are constructors for jws. in this section: jws(jwt, certdevname) creates an instance of the jws class using the specified auth.jwt payload and the certificate used for signing the jwt bearer token. jws(payload, certdevname) creates an instance of the jws class using the specified payload and certificate used for signing the jwt bearer token. jws(jwt, certdevname) creates an instance of the jws class using the specified auth.jwt payload and the certificate used for signing the jwt bearer token. signature public jws(auth.jwt jwt, string certdevname) parameters jwt type: auth.jwt the base64-encoded json claims set in the jwt bearer token generated by auth.jwt.
certdevname type: string the unique name for a certificate stored in the salesforce org’s certificate and key management page to use for signing the jwt bearer token. usage calls the tojsonstring() method in auth.jwt and sets the resulting string as the payload of the jwt bearer token. alternatively, you can specify the payload directly using jws(payload, certdevname). jws(payload, certdevname) creates an instance of the jws class using the specified payload and certificate used for signing the jwt bearer token. signature public jws(string payload, string certdevname) parameters payload type: string the base64-encoded json claims set in the jwt bearer token. 116apex reference guide jws class certdevname type: string the unique name for a certificate stored in the salesforce org’s certificate and key management page to use for signing the jwt bearer token. usage sets the payload string as the payload of the jwt bearer token. alternatively, if you generate the payload using auth.jwt, you can use jws(jwt, certdevname) instead. jws methods the following are methods for jws. all are instance methods. in this section: clone() makes a duplicate copy of the jws object. getcompactserialization() returns the compact serialization representation of the jws as a concatenated string, with the encoded jws header, encoded jws payload, and encoded jws signature strings separated by period ('.') characters. clone() makes a duplicate copy of the jws object. signature public object clone() return value type: jws getcompactserialization() returns the compact serialization representation of the jws as a concatenated string, with the encoded jws header, encoded jws payload, and encoded jws signature strings separated by period ('.') characters. signature public string getcompactserialization() return value type: string 117apex reference guide jwt class jwt class generates the json claims set in a json web token (jwt). the resulting base64-encoded payload can be passed as an argument to create an instance of the auth.jws class. namespace auth usage use the methods in this class to generate the payload in a jwt bearer token. in this section: jwt methods jwt methods the following are methods for jwt. all are instance methods. in this section: clone() makes a duplicate copy of the jwt object. getadditionalclaims() returns a map of additional claims in the jwt, where the key string contains the name of the claim, and the value contains the value of the claim. getaud() returns the audience claim that identifies the intended recipients of the jwt. getiss() returns the issuer claim that identifies the issuer of the jwt. getnbfclockskew() returns the not before claim that identifies the time before which the jwt must not be accepted for processing, while allowing some leeway for clock skew. getsub() returns the subject claim that identifies the current user of the jwt. getvaliditylength() returns the length of time (in seconds) that the jwt is valid, which affects the expiration claim. setadditionalclaims(additionalclaims) sets the additional claims in the jwt. returned by the getadditionalclaims() method. setaud(aud) sets the audience claim in the jwt. returned by the getaud() method. setiss(iss) sets the issuer claim in the jwt. returned by the getiss() method. 118apex reference guide jwt class setnbfclockskew(nbfclockskew) sets the not before claim in the jwt. returned by the getnbfclockskew() method. setsub(sub) sets the subject claim in the jwt. returned by the getsub() method. setvaliditylength(validitylength) sets the length of time (in seconds) that the jwt is valid, which affects the expiration claim. returned by the getvaliditylength() method. tojsonstring() generates the json object representation of the claims set as an encoded jwt payload. clone() makes a duplicate copy of the jwt object. signature public object clone() return value type: jwt getadditionalclaims() returns a map
of additional claims in the jwt, where the key string contains the name of the claim, and the value contains the value of the claim. signature public map<string,any> getadditionalclaims() return value type: map<string,any> getaud() returns the audience claim that identifies the intended recipients of the jwt. signature public string getaud() return value type: string 119apex reference guide jwt class getiss() returns the issuer claim that identifies the issuer of the jwt. signature public string getiss() return value type: string getnbfclockskew() returns the not before claim that identifies the time before which the jwt must not be accepted for processing, while allowing some leeway for clock skew. signature public integer getnbfclockskew() return value type: integer getsub() returns the subject claim that identifies the current user of the jwt. signature public string getsub() return value type: string getvaliditylength() returns the length of time (in seconds) that the jwt is valid, which affects the expiration claim. signature public integer getvaliditylength() return value type: integer 120apex reference guide jwt class setadditionalclaims(additionalclaims) sets the additional claims in the jwt. returned by the getadditionalclaims() method. signature public void setadditionalclaims(map<string,any> additionalclaims) parameters additionalclaims type: map<string,any> return value type: void usage additional claims must not include any standard claims. setaud(aud) sets the audience claim in the jwt. returned by the getaud() method. signature public void setaud(string aud) parameters aud type: string return value type: void setiss(iss) sets the issuer claim in the jwt. returned by the getiss() method. signature public void setiss(string iss) parameters iss type: string 121apex reference guide jwt class return value type: void setnbfclockskew(nbfclockskew) sets the not before claim in the jwt. returned by the getnbfclockskew() method. signature public void setnbfclockskew(integer nbfclockskew) parameters nbfclockskew type: integer return value type: void setsub(sub) sets the subject claim in the jwt. returned by the getsub() method. signature public void setsub(string sub) parameters sub type: string return value type: void setvaliditylength(validitylength) sets the length of time (in seconds) that the jwt is valid, which affects the expiration claim. returned by the getvaliditylength() method. signature public void setvaliditylength(integer validitylength) parameters validitylength type: integer 122apex reference guide jwtbearertokenexchange class return value type: void tojsonstring() generates the json object representation of the claims set as an encoded jwt payload. signature public string tojsonstring() return value type: string jwtbearertokenexchange class contains methods that post the signed jwt bearer token to a token endpoint to request an access token, in the oauth 2.0 jwt bearer token flow. namespace auth usage use the methods in this class to post a signed jwt bearer token to the oauth token endpoint, in exchange for an access token. example in the following example application, the apex controller: 1. creates the json claims set. 2. specifies the scope of the request with additional claims. 3. creates the signed jwt. 4. specifies the token endpoint and posts to it. 5. gets the access token from the http response. public class mycontroller{ public mycontroller() { auth.jwt jwt = new auth.jwt(); jwt.setsub('user@salesforce.com'); jwt.setaud('https://login.salesforce.com'); jwt.setiss('3mvg99oxtyemcq3gnp2pjkqezkxnmaig1xv4ohh9akl_rsk.bosv
pgzhq ukxnvjzrgsuqqgn75nl7yfkqcyy7'); //additional claims to set scope 123apex reference guide jwtbearertokenexchange class map<string, object> claims = new map<string, object>(); claims.put('scope', 'scope name'); jwt.setadditionalclaims(claims); //create the object that signs the jwt bearer token auth.jws jws = new auth.jws(jwt, 'certfromcertkeymanagement'); //get the resulting jws in case debugging is required string token = jws.getcompactserialization(); //set the token endpoint that the jwt bearer token is posted to string tokenendpoint = 'https://login.salesforce.com/services/oauth2/token'; //post the jwt bearer token auth.jwtbearertokenexchange bearer = new auth.jwtbearertokenexchange(tokenendpoint, jws); //get the access token string accesstoken = bearer.getaccesstoken(); } } in this section: jwtbearertokenexchange constructors jwtbearertokenexchange methods jwtbearertokenexchange constructors the following are constructors for jwtbearertokenexchange. in this section: jwtbearertokenexchange(tokenendpoint, jws) creates an instance of the jwtbearertokenexchange class using the specified token endpoint and the signed jwt bearer token. jwtbearertokenexchange() creates an instance of the auth.jwtbearertokenexchange class. jwtbearertokenexchange(tokenendpoint, jws) creates an instance of the jwtbearertokenexchange class using the specified token endpoint and the signed jwt bearer token. signature public jwtbearertokenexchange(string tokenendpoint, auth.jws jws) 124apex reference guide jwtbearertokenexchange class parameters tokenendpoint type: string the token endpoint that the signed jwt bearer token is posted to. jws type: auth.jws the signed jwt bearer token. jwtbearertokenexchange() creates an instance of the auth.jwtbearertokenexchange class. signature public jwtbearertokenexchange() jwtbearertokenexchange methods the following are methods for jwtbearertokenexchange. all are instance methods. in this section: clone() makes a duplicate copy of the jwtbearertokenexchange object. getaccesstoken() returns the access_token in the token response to the jwt bearer token request. getgranttype() returns the grant type specified in the jwt bearer token request. the grant type value defaults to urn:ietf:params:oauth:grant-type:jwt-bearer. gethttpresponse() returns the full system.httpresponse token response to the jwt bearer token request. getjws() returns the jws specified in the jwt bearer token request. gettokenendpoint() returns the token endpoint that the jwt bearer token request is posted to. setgranttype(granttype) sets the grant type in the jwt bearer token request. returned by the getgranttype() method. setjws(jws) sets the jws in the jwt bearer token request. returned by the getjws() method. settokenendpoint(tokenendpoint) sets the token endpoint that the jwt bearer token request is posted to. returned by the gettokenendpoint() method. 125apex reference guide jwtbearertokenexchange class clone() makes a duplicate copy of the jwtbearertokenexchange object. signature public object clone() return value type: jwtbearertokenexchange getaccesstoken() returns the access_token in the token response to the jwt bearer token request. signature public string getaccesstoken() return value type: string usage this method extracts the access_token from the token response. if the token response issues the access token in a different parameter, the request fails. if you want the full http token response returned, use gethttpresponse instead. getgranttype() returns the grant type specified in the jwt bearer token request. the grant type value defaults to urn:ietf:params:oauth:grant-type:j
wt-bearer. signature public string getgranttype() return value type: string gethttpresponse() returns the full system.httpresponse token response to the jwt bearer token request. signature public system.httpresponse gethttpresponse() 126apex reference guide jwtbearertokenexchange class return value type: system.httpresponse usage you can get the access token from the full system.httpresponse. if you want only the access_token from the token response, you can use getaccesstoken instead. getjws() returns the jws specified in the jwt bearer token request. signature public auth.jws getjws() return value type: auth.jws gettokenendpoint() returns the token endpoint that the jwt bearer token request is posted to. signature public string gettokenendpoint() return value type: string setgranttype(granttype) sets the grant type in the jwt bearer token request. returned by the getgranttype() method. signature public void setgranttype(string granttype) parameters granttype type: string return value type: void 127apex reference guide lightninglogineligibility enum setjws(jws) sets the jws in the jwt bearer token request. returned by the getjws() method. signature public void setjws(auth.jws jws) parameters jws type: auth.jws return value type: void settokenendpoint(tokenendpoint) sets the token endpoint that the jwt bearer token request is posted to. returned by the gettokenendpoint() method. signature public void settokenendpoint(string tokenendpoint) parameters tokenendpoint type: string return value type: void lightninglogineligibility enum contains a lightning login eligibility value used by the auth.sessionmanagement.getlightninglogineligibility method. usage if you use the discovery page type, users can verify themselves with lightning login. lightning login lets internal users log in with salesforce authenticator instead of a password. certain conditions must be met for lightning login to succeed. call auth.sessionmanagement.getlightninglogineligibility before or after a login attempt to get the eligibility status. you can call after a login attempt to determine why the login attempt failed. enum values the following are the values of the auth.lightninglogineligibility enum. 128apex reference guide logindiscoveryhandler interface value description eligible all eligibility conditions are met. the admin has enabled salesforce authenticator and lightning login, assigned the user lightning login user permission, and selected allow only for users with the lightning login user permission from the session settings setup page. the user has set up salesforce authenticator and enrolled in lightning login. org_authenticator_not_enabled the admin hasn’t enabled salesforce authenticator. org_pref_not_enabled the admin hasn’t enabled lightning login. the admin must select allow lightning login from the session settings setup page. user_authenticator_not_connected the user hasn’t set up salesforce authenticator. user_not_allowed the admin hasn’t granted the user allowlightninglogin user permission. allowing lightning login to certain users requires the onlyllpermuserallowed org preference. admins must select allow only for users with the lightning login user permission from the session settings setup page. user_not_enrolled the user hasn’t enrolled in lightning login. user_perm_not_enabled the admin hasn’t granted the user the lightning login eligible user permission. logindiscoveryhandler interface salesforce gives you the ability to log in users based on other verification methods than username and password. for example, it can prompt users to log in with their email, phone number, or another identifier like a federation id or device identifier. login discovery is available to these licenses: customer community, customer community plus, external identity, partner community, and partner community plus. namespace auth usage implement a auth.logindiscoveryhandler for an interview-based log in. the handler looks up a user from the identifier entered, and can call site.passwordlesslogin to determine which credential to use, such as email or sms. or the handler can redirect a user to a third-party identity provider for login. with this
handler, the login page doesn't show a password field. however, you can use site.passwordlesslogin to then prompt for a password. from the user perspective, the user enters an identifier at the log in prompt. then the user completes the login by entering a pin or password. or, if sso-enabled, the user bypasses login. for an example, see logindiscoveryhandler example implementation. for more details, see salesforce customer identity in salesforce help. in this section: logindiscoveryhandler method logindiscoveryhandler example implementation 129apex reference guide logindiscoveryhandler interface logindiscoveryhandler method here’s the method for logindiscoveryhandler. in this section: login(identifier, starturl, requestattributes) log in the customer or partner given the specified identifier, such as email or phone number. if successful, redirect the user to the experience cloud site page specified by the start url. login(identifier, starturl, requestattributes) log in the customer or partner given the specified identifier, such as email or phone number. if successful, redirect the user to the experience cloud site page specified by the start url. signature public system.pagereference login(string identifier, string starturl, map<string,string>requestattributes) parameters identifier type: string identifier the customer or partner entered at the login prompt, for example, an email address or phone number. starturl type: string path to the experience cloud site page requested by the customer or partner. the user is redirected to this location after successful login. requestattributes type: map<string,string> information about the login request based on the user’s browser state when accessing the login page. requestattributes passes in the communityurl, ipaddress, useragent, platform, application, city, country, and subdivision values. the city, country, and subdivision values come from ip geolocation. return value type: system.pagereference the url of the page where the user is redirected. example here’s a sample requestattributes response. communityurl=http://my-developer-edition.mycompany.com:5555/discover ipaddress=55.555.0.0 useragent=mozilla/5.0 (macintosh; intel mac os x 10_13_4) applewebkit/605.1.15 (khtml, like gecko) version/11.1 safari/605.1.15 platform=mac osx 130apex reference guide logindiscoveryhandler interface application=browser city=san mateo country=united states subdivision=california logindiscoveryhandler example implementation this apex code example implements the auth.logindiscoveryhandler interface. it checks whether the user who is logging in has a verified email or phone number, depending on which identifier was supplied on the login page. if verified, with auth.verificationmethod.email or auth.verificationmethod.sms, we send a challenge to the identifier, either the user’s email address or mobile device. if the user enters the code correctly on the verify page, the user is redirected to the experience cloud site’s page specified by the start url. if the user isn’t verified, the user must enter a password to log in. the handler also checks that the email and phone number are unique with this code: users.size()==1. note: passwordless login works only with verified methods. you can check the verification status on the user object, for example, with user list view, a report, or the api. make sure that your solution handles the case where the user doesn’t have a verification method. this code example falls back to a password. the default discoverable login handler checks whether the user entered a valid email address or phone number before redirecting the user to the verification page. if an invalid entry is made, the handler returns an error. because this behavior is vulnerable to user enumeration attack, make sure that your solution prevents this attack. for example, you can create a dummy page similar to the verification page and redirect the user to the dummy page when invalid user identifier is entered. also, use generic error messages to avoid providing additional information. the discoveryresult function calls the site.passwordlesslogin method to log the user in with the specified verification method. the getssoredirect function looks up whether the user logs in with saml or an auth provider. add the implementation-specific logic to handle the lookup. global class autocreateddiscloginhandler1535377170343 implements auth.logindiscoveryhandler { global
pagereference login(string identifier, string starturl, map<string, string> requestattributes) { if (identifier != null && isvalidemail(identifier)) { // search for user by email. list<user> users = [select id from user where email = :identifier and isactive = true]; if (!users.isempty() && users.size() == 1) { // user must have a verified email before using this verification method. // we cannot send messages to unverified emails. // you can check if the user's email verified bit set and add the // password verification method as fallback. list<twofactormethodsinfo> verifiedinfo = [select hasuserverifiedemailaddress from twofactormethodsinfo where userid = :users[0].id]; if (!verifiedinfo.isempty() && verifiedinfo[0].hasuserverifiedemailaddress == true) { // use email verification method if the user's email is verified. return discoveryresult(users[0], auth.verificationmethod.email, starturl, requestattributes); } else { // use password verification method as fallback // if the user's email is unverified. return discoveryresult(users[0], auth.verificationmethod.password, starturl, 131apex reference guide logindiscoveryhandler interface requestattributes); } } else { throw new auth.logindiscoveryexception('no unique user found. user count=' + users.size()); } } if (identifier != null) { string formattedsms = getformattedsms(identifier); if (formattedsms != null) { // search for user by sms. list<user> users = [select id from user where mobilephone = :formattedsms and isactive = true]; if (!users.isempty() && users.size() == 1) { // user must have a verified sms before using this verification method. // we cannot send messages to unverified mobile numbers. // you can check if the user's mobile verified bit is set or add // the password verification method as fallback. list<twofactormethodsinfo> verifiedinfo = [select hasuserverifiedmobilenumber from twofactormethodsinfo where userid = :users[0].id]; if (!verifiedinfo.isempty() && verifiedinfo[0].hasuserverifiedmobilenumber == true) { // use sms verification method if the user's mobile number is verified. return discoveryresult(users[0], auth.verificationmethod.sms, starturl, requestattributes); } else { // use password verification method as fallback if the user's // mobile number is unverified. return discoveryresult(users[0], auth.verificationmethod.password, starturl, requestattributes); } } else { throw new auth.logindiscoveryexception('no unique user found. user count=' + users.size()); } } } if (identifier != null) { // you can customize the code to find user via other attributes, // such as ssn or federation id. } throw new auth.logindiscoveryexception('invalid identifier'); } private boolean isvalidemail(string identifier) { string emailregex = '^[a-za-z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-za-z0-9.-]+\\.[a-za-z]{2,4}$'; // source: https://www.regular-expressions.info/email.html pattern emailpattern = pattern.compile(emailregex); matcher emailmatcher = emailpattern.matcher(identifier); if (emailmatcher.matches()) { return true; } else { return false; } } private string getformattedsms(string identifier) { 132
apex reference guide logindiscoveryhandler interface // accept sms input formats with 1- or 2-digit country code, // 3-digit area code, and 7-digit number. // you can customize the sms regex to allow different formats. string smsregex = '^(\\+?\\d{1,2}?[\\s-])?(\\(?\\d{3}\\)?[\\s-]?\\d{3}[\\s-]?\\d{4})$'; pattern smspattern = pattern.compile(smsregex); matcher smsmatcher = smspattern.matcher(identifier); if (smsmatcher.matches()) { try { // format user input into the verified sms format '+xx xxxxxxxxxx' // before db lookup. if no country code is provided, append // us country code +1 for the default. string countrycode = smsmatcher.group(1) == null ? '+1' : smsmatcher.group(1); return system.usermanagement.formatphonenumber(countrycode, smsmatcher.group(2)); } catch(system.invalidparametervalueexception e) { return null; } } else { return null; } } private pagereference getssoredirect(user user, string starturl, map<string, string> requestattributes) { // you can look up to check whether the user should log in with // saml or an auth provider and return the url to initialize sso. return null; } private pagereference discoveryresult(user user, auth.verificationmethod method, string starturl, map<string, string> requestattributes) { // only users with an external identity or community license can log in // using site.passwordlesslogin. use getssoredirect to let your org employees // log in to an experience cloud site. pagereference ssoredirect = getssoredirect(user, starturl, requestattributes); if (ssoredirect != null) { return ssoredirect; } else { if (method != null) { list<auth.verificationmethod> methods = new list<auth.verificationmethod>(); methods.add(method); pagereference pwdlessredirect = site.passwordlesslogin(user.id, methods, starturl); if (pwdlessredirect != null) { return pwdlessredirect; } else { throw new auth.logindiscoveryexception('no passwordless login redirect url returned for verification method: ' + method); } } else { throw new auth.logindiscoveryexception('no method found'); } } } } 133apex reference guide logindiscoveryhandler interface code example: filter login discovery users by profile your production org can have multiple users with the same verified email address and mobile number. but your customers must have unique ones. to address this problem, you can add a few lines of code that filters users by profile to ensure uniqueness. this code example handles users with the external identity user profile, but can be adapted to support other use cases. for example, you can modify the first line of code to address users with other user licenses or criteria. login discovery is available with the following user licenses: customer community, customer community plus, external identity, partner community, and partner community plus. it depends on which profiles have access to your experience cloud site. global class autocreateddiscloginhandler1551301979709 implements auth.logindiscoveryhandler { global pagereference login(string identifier, string starturl, map<string, string> requestattributes) { if (identifier != null && isvalidemail(identifier)) { // ensure uniqueness by profile profile p = [select id from profile where name = 'external identity user']; list<user> users = [select id from user where email = :identifier and isactive = true and profileid=:p.id]; if (!users.isempty() && users.size() == 1) { // user must have verified email before using this verification method. we cannot send messages to unverified emails. // you can check if the user has email verified bit on and add the password verification method as fallback. list<twofactormethodsinfo> verifiedinfo = [select hasuserverifiedemailaddress from twofactormethodsinfo where userid = :users[0].id]; if (!verifiedinfo.isempty() && verifiedinfo[0].hasuserverifiedemailaddress == true) {
// use email verification method if the user's email is verified. return discoveryresult(users[0], auth.verificationmethod.email, starturl, requestattributes); } else { // use password verification method as fallback if the user's email is unverified. return discoveryresult(users[0], auth.verificationmethod.password, starturl, requestattributes); } } else { throw new auth.logindiscoveryexception('no unique user found. user count=' + users.size()); } } if (identifier != null) { string formattedsms = getformattedsms(identifier); if (formattedsms != null) { // ensure uniqueness by profile profile p = [select id from profile where name = 'external identity user']; list<user> users = [select id from user where mobilephone = :formattedsms and isactive = true and profileid=:p.id]; if (!users.isempty() && users.size() == 1) { // user must have verified sms before using this verification method. we cannot send messages to unverified mobile numbers. // you can check if the user has mobile verified bit on or add the password verification method as fallback. 134apex reference guide logindiscoveryhandler interface list<twofactormethodsinfo> verifiedinfo = [select hasuserverifiedmobilenumber from twofactormethodsinfo where userid = :users[0].id]; if (!verifiedinfo.isempty() && verifiedinfo[0].hasuserverifiedmobilenumber == true) { // use sms verification method if the user's mobile number is verified. return discoveryresult(users[0], auth.verificationmethod.sms, starturl, requestattributes); } else { // use password verification method as fallback if the user's mobile number is unverified. return discoveryresult(users[0], auth.verificationmethod.password, starturl, requestattributes); } } else { throw new auth.logindiscoveryexception('no unique user found. user count=' + users.size()); } } } if (identifier != null) { // you can customize the code to find user via other attributes, such as ssn or federation id } throw new auth.logindiscoveryexception('invalid identifier'); } private boolean isvalidemail(string identifier) { string emailregex = '^[a-za-z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-za-z0-9.-]+\\.[a-za-z]{2,4}$'; // source: https://www.regular-expressions.info/email.html pattern emailpattern = pattern.compile(emailregex); matcher emailmatcher = emailpattern.matcher(identifier); if (emailmatcher.matches()) { return true; } else { return false; } } private string getformattedsms(string identifier) { // accept sms input formats with 1 or 2 digits country code, 3 digits area code and 7 digits number // you can customize the sms regex to allow different formats string smsregex = '^(\\+?\\d{1,2}?[\\s-])?(\\(?\\d{3}\\)?[\\s-]?\\d{3}[\\s-]?\\d{4})$'; pattern smspattern = pattern.compile(smsregex); matcher smsmatcher = smspattern.matcher(identifier); if (smsmatcher.matches()) { try { // format user input into the verified sms format '+xx xxxxxxxxxx' before db lookup // append us country code +1 by default if no country code is provided string countrycode = smsmatcher.group(1) == null ? '+1' : smsmatcher.group(1); return system.usermanagement.formatphonenumber(countrycode, smsmatcher.group(2)); 135apex reference guide logindiscoverymethod enum } catch(system.invalidparametervalueexception e) { return null; } } else { return null; } } private pagereference getssoredirect(user user, string starturl, map<string, string> requestattributes) { // you can look up if the user should log in with saml or an auth provider
and return the url to initialize sso. return null; } private pagereference discoveryresult(user user, auth.verificationmethod method, string starturl, map<string, string> requestattributes) { //only users with an external identity or community license can login using site.passwordlesslogin //use getssoredirect to enable your org employees to log in to an experience cloud site pagereference ssoredirect = getssoredirect(user, starturl, requestattributes); if (ssoredirect != null) { return ssoredirect; } else { if (method != null) { list<auth.verificationmethod> methods = new list<auth.verificationmethod>(); methods.add(method); pagereference pwdlessredirect = site.passwordlesslogin(user.id, methods, starturl); if (pwdlessredirect != null) { return pwdlessredirect; } else { throw new auth.logindiscoveryexception('no passwordless login redirect url returned for verification method: ' + method); } } else { throw new auth.logindiscoveryexception('no method found'); } } } } logindiscoverymethod enum contains methods used to verify the user’s identity when the my domain login process uses login discovery. usage specifies the verification method used to authenticate internal users when my domain is set up for login discovery. enum values auth.logindiscoverymethod enum has the following values. 136apex reference guide mydomainlogindiscoveryhandler interface value description lightning_login verify identity by lightning login, which lets internal users log in with salesforce authenticator. password verify identity by entering a password. mydomainlogindiscoveryhandler interface the handler used to implement the my domain login discovery page, which is an interview-based (two-step) login process. first the user is prompted for a unique identifier such as an email address or phone number. then the handler determines (discovers) how to authenticate the user. either the user enters a password or is directed to an identity provider’s login page. namespace auth usage implement mydomainlogindiscoveryhandler to let my domain users log in with something other than their username and password. this handler contains the logic to look up the user based on the identifier value entered on the login page. the auth.mydomainlogindiscoveryhandler.login method is invoked when the identifier page is submitted and finds the user that corresponds to the submitted identifier. the auth.sessionmanagement.finishlogindiscovery method sends the user to the authentication mechanism and then logs in the user. register the handler from the my domain setup page. under authentication configuration, select the discovery login page type. for login discovery handler, select this handler from the list of apex classes. for an example, see mydomainlogindiscoveryhandler example implementation. for more details, search for my domain login discovery in salesforce help. in this section: mydomainlogindiscoveryhandler method mydomainlogindiscoveryhandler example implementation mydomainlogindiscoveryhandler method mydomainlogindiscoveryhandler has the following method. in this section: login(identifier, starturl, requestattributes) log in a salesforce user given the specified identifier, such as email or phone number. if successful, redirect the user to the page specified by the start url. 137apex reference guide mydomainlogindiscoveryhandler interface login(identifier, starturl, requestattributes) log in a salesforce user given the specified identifier, such as email or phone number. if successful, redirect the user to the page specified by the start url. signature public system.pagereference login(string identifier, string starturl, map<string,string> requestattributes) parameters identifier type: string identifier the salesforce user entered at the login prompt, for example, an email address or phone number. starturl type: string the page users see after successfully logging in to the my domain subdomain. requestattributes type: map <string, string> information about the login request based on the user’s browser state when accessing the login page. requestattributes passes in the mydomainurl, ipaddress, useragent, platform, application, city, country, and subdivision values. the city, country, and subdivision values come from ip address geolocation. return value type: system.pagereference the url of the page where the user is redirected to complete authentication. example here’s
a sample requestattributes response. communityurl=http://my-dev-ed.my.salesforce.com:5555/discover ipaddress=55.255.0.0 useragent=mozilla/5.0 (macintosh; intel mac os x 10_13_4) applewebkit/605.1.15 (khtml, like gecko) version/11.1 safari/605.1.15 platform=mac osx application=browser city=san mateo country=united states subdivision=california mydomainlogindiscoveryhandler example implementation here's an example of the auth.mydomainlogindiscoveryhandler interface. this sample class contains the default logic for my domain login discovery using password authentication. you can customize the code to ensure it meets your needs. the requestattributes parameter provides additional information that you can use in the discovery logic. attributes include mydomainurl, 138apex reference guide mydomainlogindiscoveryhandler interface ipaddress, useragent, and location information (such as country and city). use auth.discoverycustomerrorexception to throw custom errors to display on the login page. to implement this interface, the my domain login page type must be set to discovery. // this sample class contains the default logic for my domain login discovery by password. // you can customize the code to ensure it meets your needs. the requestattributes parameter // provides additional information you can use in the discovery logic. attributes include mydomainurl, // ipaddress, useragent, and location information (such as country and city). // use auth.discoverycustomerrorexception to throw custom errors which will be shown on login page. global class mydomaindisclogindefaulthandler implements auth.mydomainlogindiscoveryhandler { global pagereference login(string identifier, string starturl, map<string, string> requestattributes) { if (identifier != null) { // search for user by email list<user> users = [select id from user where email = :identifier and isactive = true]; if (!users.isempty() && users.size() == 1) { return discoveryresult(users[0], starturl, requestattributes); } else { throw new auth.logindiscoveryexception('no unique user found. user count=' + users.size()); } } throw new auth.logindiscoveryexception('invalid identifier'); } private pagereference getssoredirect(user user, string starturl, map<string, string> requestattributes) { //youcanlookupiftheusershouldloginwithsamloranauthproviderandreturntheurltoinitializesso.forexample: // samlssoconfig sso = [select id from samlssoconfig where developername='samltest' limit 1]; // to get the url for a my domain subdomain, you can pass null in the communityurl parameter. // string ssourl = auth.authconfiguration.getsamlssourl(null, starturl, sso.id); // return new pagereference(ssourl); return null; } private pagereference discoveryresult(user user, string starturl, map<string, string> requestattributes) { pagereference ssoredirect = getssoredirect(user, starturl, requestattributes); if (ssoredirect != null) { return ssoredirect; } else { return auth.sessionmanagement.finishlogindiscovery(auth.logindiscoverymethod.password, user.id); } } } 139apex reference guide mydomainlogindiscoveryhandler interface test class for mydomaindisclogindefaulthandler class the following is the test class for mydomaindiscoveryloginhandler. for the test to work, your org must have the my domain login page type set to discovery. // test class for mydomaindisclogindefaulthandler @istest class mydomaindisclogindefaulthandlertest { /* test discoverable handler login. create a user with specific email identifier and invoke login. expected : user should be discovered and pagereference should be returned. */ @istest static void testlogin() { // create user string identifieremail = getuniquename() + '@test.org'; createtestuser(identifieremail); map<string, string> requestattributes = new map<string, string>(); string starturl = ''; mydomaindisclogindefaulthandlermydomaindisclogindefaulthandler=newmydomaindisclogindefaulthandler(); // invoke login method from handler with the email of user created pagereference pagereference=mydomaindisclogin
defaulthandler.login(identifieremail,starturl,requestattributes); // asser page reference is returned system.assertnotequals(null, pagereference, 'page reference was not returned'); } /* test discoverable handler login with invalid (non-existing) user. expected : auth.logindiscoveryexception */ @istest static void testloginwithinvaliduser() { try { map<string, string> requestattributes = new map<string, string>(); string starturl = ''; string uniquename = getuniquename(); string email = uniquename + '@test.org'; mydomaindisclogindefaulthandlermydomaindisclogindefaulthandler=newmydomaindisclogindefaulthandler(); // invoke login method from handler with non-existing user mydomaindisclogindefaulthandler.login(email, starturl, requestattributes); }catch (auth.logindiscoveryexception logindiscoveryexception) { // assert exception message system.assert(logindiscoveryexception.getmessage().contains('nouniqueuserfound'),'message='+logindiscoveryexception.getmessage()); } } /* generate a random name */ private static string getuniquename() { string orgid = userinfo.getorganizationid(); string datestring = string.valueof(datetime.now()).replace(' ','').replace(':','').replace('-',''); integer randomint = integer.valueof(math.rint(math.random()*1000000)); string uniquename = orgid + datestring + randomint; return uniquename; } /* create user with given email. */ private static void createtestuser(string identifieremail) 140apex reference guide oauthrefreshresult class { string uniquename = getuniquename(); profile pf = [select id from profile where name='standard user']; string profileid = pf.id; string fname = 'fname'; string lname = uniquename + '-lname'; user tuser = new user( firstname = fname, lastname = lname, email = identifieremail, username = uniquename + '@test.org', emailencodingkey = 'iso-8859-1', alias = uniquename.substring(18, 23), timezonesidkey = 'america/los_angeles', localesidkey = 'en_us', languagelocalekey = 'en_us', profileid = profileid); insert tuser; } } oauthrefreshresult class stores the result of an authproviderpluginclass refresh method. oauth authentication flow provides a refresh token that can be used to get a new access token. access tokens have a limited lifetime as specified by the session timeout value. when an access token expires, use a refresh token to get a new access token. namespace auth usage the oauthrefreshresult class contains the parameters, accesstoken, refreshtoken, and error, all of which are of type string. for a code example, see . in this section: oauthrefreshresult constructors oauthrefreshresult properties oauthrefreshresult constructors the following are constructors for oauthrefreshresult. in this section: oauthrefreshresult(accesstoken, refreshtoken, error) creates an instance of the oauthrefreshresult class using the specified access token, refresh token, and error for a custom authentication provider plug-in. 141apex reference guide oauthrefreshresult class oauthrefreshresult(accesstoken, refreshtoken) creates an instance of the oauthrefreshresult class using the specified access token and refresh token for a custom authentication provider plug-in. use this method when you know that the refresh was successful. oauthrefreshresult(accesstoken, refreshtoken, error) creates an instance of the oauthrefreshresult class using the specified access token, refresh token, and error for a custom authentication provider plug-in. signature public oauthrefreshresult(string accesstoken, string refreshtoken, string error) parameters accesstoken type: string oauth access token for the user who is currently logged in. refreshtoken type: string oauth refresh token for the user who is currently logged in. error type: string error that occurred when a user attempted to authenticate with the custom authentication provider. oauthrefreshresult(accesstoken, refreshtoken) creates an instance of the oauthrefreshresult class using the specified
access token and refresh token for a custom authentication provider plug-in. use this method when you know that the refresh was successful. signature public oauthrefreshresult(string accesstoken, string refreshtoken) parameters accesstoken type: string the oauth access token for the user who is logged in. refreshtoken type: string the oauth refresh token for the user who is logged in. oauthrefreshresult properties the following are properties for oauthrefreshresult. 142apex reference guide registrationhandler interface in this section: accesstoken the oauth access token for the user who is currently logged in. error error that occurs when a user unsuccessfully attempts to authenticate with the custom authentication provider. refreshtoken the oauth refresh token for the user who is currently logged in. accesstoken the oauth access token for the user who is currently logged in. signature public string accesstoken {get; set;} property value type: string error error that occurs when a user unsuccessfully attempts to authenticate with the custom authentication provider. signature public string error {get; set;} property value type: string refreshtoken the oauth refresh token for the user who is currently logged in. signature public string refreshtoken {get; set;} property value type: string registrationhandler interface salesforce provides the ability to use an authentication provider, such as facebook© or janrain©, for single sign-on into salesforce. 143apex reference guide registrationhandler interface namespace auth usage to set up single sign-on, you must create a class that implements auth.registrationhandler. classes implementing the auth.registrationhandler interface are specified as the registration handler in authentication provider definitions, and enable single sign-on into salesforce portals and organizations from third-party services such as facebook. using information from the authentication providers, your class must perform the logic of creating and updating user data as appropriate, including any associated account and contact records. note: during the user update process, you can use the confirmuser() method to ensure that users are correctly mapped between salesforce and the third party. for more information, see the confirmuserregistrationhandler interface. in this section: registrationhandler methods storing user information and getting access tokens auth.registrationhandler example implementation auth.registrationhandler error example this example implements the auth.registrationhandler interface and shows how to use a custom exception to display an error message in the url of the page. if you don’t use a custom exception, the error code and description appear in the url and the error description appears on the page. registrationhandler methods the following are methods for registrationhandler. in this section: createuser(portalid, userdata) returns a user object using the specified portal id and user information from the third party, such as the username and email address. the user object corresponds to the third party’s user information and may be a new user that hasn’t been inserted in the database or may represent an existing user record in the database. updateuser(userid, portalid, userdata) updates the specified user’s information. this method is called if the user has logged in before with the authentication provider and then logs in again. createuser(portalid, userdata) returns a user object using the specified portal id and user information from the third party, such as the username and email address. the user object corresponds to the third party’s user information and may be a new user that hasn’t been inserted in the database or may represent an existing user record in the database. signature public user createuser(id portalid, auth.userdata userdata) 144apex reference guide registrationhandler interface parameters portalid type: id userdata type: auth.userdata return value type: user usage the portalid value may be null or an empty key if there is no portal configured with this provider. updateuser(userid, portalid, userdata) updates the specified user’s information. this method is called if the user has logged in before with the authentication provider and then logs in again. signature public void updateuser(id userid, id portalid, auth.userdata userdata) parameters userid type: id portalid type: id userdata type: auth.userdata return value type: void usage the portalid value can be null or an empty key if there's no portal configured with this provider. storing user information and getting access tokens the
auth.userdata class is used to store user information for auth.registrationhandler. the third-party authentication provider can send back a large collection of data about the user, including their username, email address, locale, and so on. frequently used data is converted into a common format with the auth.userdata class and sent to the registration handler. if the registration handler wants to use the rest of the data, the auth.userdata class has an attributemap variable. the attribute map is a map of strings (map<string, string>) for the raw values of all the data from the third party. because the map is <string, string>, values that the third party returns that aren't strings (like an array of urls or a map) are converted into an 145apex reference guide registrationhandler interface appropriate string representation. the map includes everything returned by the third-party authentication provider, including the items automatically converted into the common format. the constructor for auth.userdata has the following syntax: auth.userdata(string identifier, string firstname, string lastname, string fullname, string email, string link, string username, string locale, string provider, string siteloginurl, map<string, string> attributemap) to learn about auth.userdata properties, see auth.userdata class. note: you can only perform dml operations on additional sobjects in the same transaction with user objects under certain circumstances. for more information, see sobjects that cannot be used together in dml operations. for all authentication providers except janrain, after a user is authenticated using a provider, the access token associated with that provider for this user can be obtained in apex using the auth.authtoken apex class. auth.authtoken provides two methods to retrieve access tokens. one is getaccesstoken, which obtains a single access token. use this method if the user id is mapped to a single third-party user. if the user id is mapped to multiple third-party users, use getaccesstokenmap, which returns a map of access tokens for each third-party user. for more information about authentication providers, see authentication providers in salesforce help. when using janrain as an authentication provider, you must use the janrain accesscredentials dictionary values to retrieve the access token or its equivalent. only some providers supported by janrain provide an access token, while other providers use other fields. the janrain accesscredentials fields are returned in the attributemap variable of the auth.userdata class. see the janrain auth_info documentation for more information on accesscredentials. note: not all janrain account types return accesscredentials. sometimes you must change your account type to receive the information. to learn about the auth.authtoken methods, see auth.authtoken class. auth.registrationhandler example implementation this example implements the auth.registrationhandler interface that creates as well as updates a standard user based on data provided by the authentication provider. error checking has been omitted to keep the example simple. global class standarduserregistrationhandler implements auth.registrationhandler{ global user createuser(id portalid, auth.userdata data){ user u = new user(); profile p = [select id from profile where name='standard user']; u.username = data.username + '@salesforce.com'; u.email = data.email; u.lastname = data.lastname; u.firstname = data.firstname; string alias = data.username; if(alias.length() > 8) { alias = alias.substring(0, 8); 146apex reference guide registrationhandler interface } u.alias = alias; u.languagelocalekey = data.attributemap.get('language'); u.localesidkey = data.locale; u.emailencodingkey = 'utf-8'; u.timezonesidkey = 'america/los_angeles'; u.profileid = p.id; return u; } global void updateuser(id userid, id portalid, auth.userdata data){ user u = new user(id=userid); u.username = data.username + '@salesforce.com'; u.email = data.email; u.lastname = data.lastname; u.firstname = data.firstname; string alias = data.username; if(alias.length() > 8) { alias = alias.substring(0, 8); } u.alias = alias; u.langu
agelocalekey = data.attributemap.get('language'); u.localesidkey = data.locale; update(u); } } the following example tests the above code. @istest private class standarduserregistrationhandlertest { static testmethod void testcreateandupdateuser() { standarduserregistrationhandler handler = new standarduserregistrationhandler(); auth.userdata sampledata = new auth.userdata('testid', 'testfirst', 'testlast', 'testfirst testlast', 'testuser@example.org', null, 'testuserlong', 'en_us', 'facebook', null, new map<string, string>{'language' => 'en_us'}); user u = handler.createuser(null, sampledata); system.assertequals('testuserlong@salesforce.com', u.username); system.assertequals('testuser@example.org', u.email); system.assertequals('testlast', u.lastname); system.assertequals('testfirst', u.firstname); system.assertequals('testuser', u.alias); insert(u); string uid = u.id; sampledata = new auth.userdata('testnewid', 'testnewfirst', 'testnewlast', 'testnewfirst testnewlast', 'testnewuser@example.org', null, 'testnewuserlong', 'en_us', 'facebook', null, new map<string, string>{}); handler.updateuser(uid, null, sampledata); user updateduser = [select username, email, firstname, lastname, alias from user where id=:uid]; system.assertequals('testnewuserlong@salesforce.com', updateduser.username); 147apex reference guide samljithandler interface system.assertequals('testnewuser@example.org', updateduser.email); system.assertequals('testnewlast', updateduser.lastname); system.assertequals('testnewfirst', updateduser.firstname); system.assertequals('testnewu', updateduser.alias); } } auth.registrationhandler error example this example implements the auth.registrationhandler interface and shows how to use a custom exception to display an error message in the url of the page. if you don’t use a custom exception, the error code and description appear in the url and the error description appears on the page. to limit this example to the custom exception, some code was omitted. global class reghandler implements auth.registrationhandler { class reghandlerexception extends exception {} global user createuser(id portalid, auth.userdata data){ list<profile> profiles = [select id, name, usertype from profile where name = 'power user']; profile profile = profiles.isempty() ? null : profiles[0]; if(profile==null) throw new reghandlerexception('cannot find the profile. for help, contact your administrator.'); ... } global void updateuser(id userid, id portalid, auth.userdata data){ user u = new user(id=userid); u.lastname = data.lastname; u.firstname = data.firstname; update(u); } } samljithandler interface use this interface to control and customize just-in-time user provisioning logic during saml single sign-on. namespace auth usage to use custom logic for user provisioning during saml single sign-on, you must create a class that implements auth.samljithandler. this allows you to incorporate organization-specific logic (such as populating custom fields) when users log in to salesforce with single sign-on. keep in mind that your class must perform the logic of creating and updating user data as appropriate, including any associated account and contact records. 148apex reference guide samljithandler interface in salesforce, you specify your class that implements this interface in the saml jit handler field in saml single sign-on settings. make sure that the user you specify to run the class has “manage users” permission. in this section: samljithandler methods samljithandler example implementation samljithandler methods the following are methods for samljithandler. in this section: createuser(samlssoproviderid, communityid, portalid, federationid, attributes, assertion) returns a user object using the specified federation id
. the user object corresponds to the user information. this object can be a new user that hasn’t been inserted in the database or an existing user record in the database. updateuser(userid, samlssoproviderid, communityid, portalid, federationid, attributes, assertion) updates the specified user’s information. this method is called if the user has logged in before with saml single sign-on and then logs in again, or if your application is using the existing user linking url. createuser(samlssoproviderid, communityid, portalid, federationid, attributes, assertion) returns a user object using the specified federation id. the user object corresponds to the user information. this object can be a new user that hasn’t been inserted in the database or an existing user record in the database. signature public user createuser(id samlssoproviderid, id communityid, id portalid, string federationid, map<string,string> attributes, string assertion) parameters samlssoproviderid type: id the id of the samlssoconfig standard object. communityid type: id the id of the experience cloud site. this parameter can be null if you’re not creating an experience cloud user. portalid type: id the id of the portal. this parameter can be null if you’re not creating a portal user. federationid type: string the id salesforce expects to be used for this user. 149apex reference guide samljithandler interface attributes type: map<string,string> all attributes in the saml assertion that were added to the default assertion; for example, custom attributes. attributes are case-sensitive. if the assertion is encrypted, the attribute map contains a decrypted assertion stored as a value with the key sfdc.samlassertion. assertion type: string the default saml assertion, base-64 encoded. if the assertion is encrypted, this parameter is also encrypted. to access the decrypted assertion, see the sfdc.samlassertion key in the attribute map. return value type: user a user sobject. usage the communityid and portalid parameter values can be null or the associated keys can be empty if there’s no experience cloud site or portal configured with this organization. updateuser(userid, samlssoproviderid, communityid, portalid, federationid, attributes, assertion) updates the specified user’s information. this method is called if the user has logged in before with saml single sign-on and then logs in again, or if your application is using the existing user linking url. signature public void updateuser(id userid, id samlssoproviderid, id communityid, id portalid, string federationid, map<string,string> attributes, string assertion) parameters userid type: id the id of the salesforce user. samlssoproviderid type: id the id of the samlssoconfig object. communityid type: id the id of the experience cloud site. this type can be null if you’re not updating an experience cloud user. 150apex reference guide samljithandler interface portalid type: id the id of the portal. this type can be null if you’re not updating a portal user. federationid type: string the id salesforce expects to be used for this user. attributes type: map<string,string> all attributes in the saml assertion that were added to the default assertion; for example, custom attributes. attributes are case-sensitive. if the assertion is encrypted, the attribute map also contains a decrypted assertion stored as a value with the key sfdc.samlassertion. assertion type: string the default saml assertion, base-64 encoded. if the assertion is encrypted, this parameter is also encrypted. to access the decrypted assertion, see the sfdc.samlassertion key in the attribute map. return value type: void samljithandler example implementation this is an example implementation of the auth.samljithandler interface. this code uses private methods to handle accounts and contacts (handlecontact() and handleaccount()), which aren’t included in this example. global class standarduserhandler implements auth.samljithandler { private class jitexception extends exception{} private void handleuser(boolean
create, user u, map<string, string> attributes, string federationidentifier, boolean isstandard) { if(create && attributes.containskey('user.username')) { u.username = attributes.get('user.username'); } if(create) { if(attributes.containskey('user.federationidentifier')) { u.federationidentifier = attributes.get('user.federationidentifier'); } else { u.federationidentifier = federationidentifier; } } if(attributes.containskey('user.profileid')) { string profileid = attributes.get('user.profileid'); profile p = [select id from profile where id=:profileid]; u.profileid = p.id; } if(attributes.containskey('user.userroleid')) { string userrole = attributes.get('user.userroleid'); 151apex reference guide sessionmanagement class userrole r = [select id from userrole where id=:userrole]; u.userroleid = r.id; } if(attributes.containskey('user.phone')) { u.phone = attributes.get('user.phone'); } if(attributes.containskey('user.email')) { u.email = attributes.get('user.email'); } //more attributes here - removed for length //handle custom fields here if(!create) { update(u); } } private void handlejit(boolean create, user u, id samlssoproviderid, id communityid, id portalid, string federationidentifier, map<string, string> attributes, string assertion) { if(communityid != null || portalid != null) { string account = handleaccount(create, u, attributes); handlecontact(create, account, u, attributes); handleuser(create, u, attributes, federationidentifier, false); } else { handleuser(create, u, attributes, federationidentifier, true); } } global user createuser(id samlssoproviderid, id communityid, id portalid, string federationidentifier, map<string, string> attributes, string assertion) { user u = new user(); handlejit(true, u, samlssoproviderid, communityid, portalid, federationidentifier, attributes, assertion); return u; } global void updateuser(id userid, id samlssoproviderid, id communityid, id portalid, string federationidentifier, map<string, string> attributes, string assertion) { user u = [select id from user where id=:userid]; handlejit(false, u, samlssoproviderid, communityid, portalid, federationidentifier, attributes, assertion); } } sessionmanagement class contains methods for verifying users’ identity, creating custom login flows, customizing security levels, and defining trusted ip ranges for a current session. 152apex reference guide sessionmanagement class namespace auth in this section: sessionmanagement methods sessionmanagement methods the following are methods for sessionmanagement. all methods are static. use these methods to customize your user identity verification flows, manage the use of time-based one-time password (totp) apps like google authenticator, or create custom login flows. other methods validate a user’s incoming ip address against trusted ip range settings for an organization or profile. in this section: finishlogindiscovery(method, userid) finishes the my domain login discovery login process. finishloginflow() finish the visualforce page login flow process, and redirect the user to the default home page. finishloginflow(starturl) finish the visualforce page login flow process, and redirect the user to the specified start url. generateverificationurl(policy, description, destinationurl) initiates a user identity verification flow with the verification method that the user registered with, and returns a url to the identity verification screen. for example, if you have a custom visualforce page that displays sensitive account details, you can prompt the user to verify identity before viewing it. getcurrentsession() returns a map of attributes for the current session. getlightninglogineligibility(userid) returns the eligibility status for a user who’s logging in with lightning login when you set up your org with my domain and use the login discovery page type. use this method to redirect
the user to a custom login flow. for example, use after a login attempt to redirect the user to password flow if the user is ineligible for lightning login. getqrcode() returns a map containing a url to a quick response (qr) code and a time-based one-time password (totp) shared secret to configure authenticator apps or devices for multi-factor authentication (mfa). getrequiredsessionlevelforprofile(profileid) indicates the required login security session level for the given profile. ignoreforconcurrentsessionlimit(sessions) this method is reserved for internal salesforce use. inorgnetworkrange(ipaddress) indicates whether the given ip address is within the organization's trusted ip range according to the organization's network access settings. isipallowedforprofile(profileid, ipaddress) indicates whether the given ip address is within the trusted ip range for the given profile. 153apex reference guide sessionmanagement class setsessionlevel(level) sets the user's current session security level. validatetotptokenforkey(sharedkey, totpcode) deprecated. use validatetotptokenforkey(totpsharedkey, totpcode, description) instead. validatetotptokenforkey(totpsharedkey, totpcode, description) indicates whether a time-based one-time password (totp) code (token) is valid for the given shared key. validatetotptokenforuser(totpcode) deprecated. use validatetotptokenforuser(totpcode, description) instead. validatetotptokenforuser(totpcode, description) indicates whether a time-based one-time password (totp) code (token) is valid for the current user. verifydeviceflow(usercode, starturl) verifies the user code entered during the device authentication flow and redirects users to the oauth approval page. if users aren’t logged in, they must log in. after successful login, users are prompted to allow the device to access salesforce data. finishlogindiscovery(method, userid) finishes the my domain login discovery login process. signature public static system.pagereference finishlogindiscovery(auth.logindiscoverymethod method, id userid) parameters method type: auth.logindiscoverymethod logindiscoverymethod enum verification method used with my domain login discovery. userid type: id id used to log in the user. the user must be active. return value type: system.pagereference usage include this method when implementing the mydomainlogindiscoveryhandler interface to direct users to an authentication mechanism, and then log them in. if users enter a username in the login page, they are sent to the password page for authentication. if users are enrolled in lightning login, they are directed to the salesforce authenticator to authenticate. if users are sso-enabled, they are sent to the suitable identity provider (idp) to authenticate. the calling user requires manage users permission. if the user passed in is frozen or inactive, the method throws an exception. after implementing the mydomainlogindiscoveryhandler interface, register the login discovery handler from the my domain setup page. under authentication configuration, select this handler from the list of apex classes. 154apex reference guide sessionmanagement class finishloginflow() finish the visualforce page login flow process, and redirect the user to the default home page. signature public static system.pagereference finishloginflow() return value type: system.pagereference usage include this method in the apex controller of the visualforce page login flow when creating login flows programmatically. this method indicates that the login flow is finished and redirects the user to the experience cloud site’s default home page. the login process runs in a restricted session until users complete the process. calling this method indicates that the login flow is complete, lifts the restriction, and gives users full access to the experience cloud site. finishloginflow(starturl) finish the visualforce page login flow process, and redirect the user to the specified start url. signature public static system.pagereference finishloginflow(string starturl) parameters starturl type: string path to the page that users see when they access the experience cloud site. return value type: system.pagereference usage include this method in the apex controller of the visualforce page login flow when creating login flows programmatically. this method indicates that
the login flow is finished and redirects the user to the specified location in the experience cloud site. the login process runs in a restricted session until users complete the process. calling this method indicates that the login flow is complete, lifts the restriction, and gives users full access to the experience cloud site. generateverificationurl(policy, description, destinationurl) initiates a user identity verification flow with the verification method that the user registered with, and returns a url to the identity verification screen. for example, if you have a custom visualforce page that displays sensitive account details, you can prompt the user to verify identity before viewing it. 155apex reference guide sessionmanagement class signature public static string generateverificationurl(auth.verificationpolicy policy, string description, string destinationurl) parameters policy type: auth.verificationpolicy the session security policy required to initiate identity verification for the user’s session. for example, if the policy is set to high assurance level of session security, and the user’s current session has the standard level of session security, the user’s session is raised to high assurance after successful verification of identity. in the setup user interface, this value is shown in the triggered by column of identity verification history. description type: string the custom description that describes the activity requiring identity verification; for example, “complete purchase and check out”. this text appears to users when they verify their identity in salesforce and, if they use salesforce authenticator version 2 or later, in the salesforce authenticator mobile app. in addition, in the setup user interface, this text is shown in the activity message column of identity verification history. destinationurl type: string the relative or absolute salesforce url that you want to redirect the user to after identity verification—for example, /apex/mypage. the user is redirected to destinationurl when the identity verification flow is complete, regardless of success. for example, if a user chooses to not respond to the identity challenge and cancels it, the user is still redirected to destinationurl. as a best practice, ensure that your code for this page manually checks that the security policy was satisfied (and the user didn’t just manually type the url in the browser). for example, if the policy is high assurance, the target page checks that the user's session is high assurance before allowing access. return value type: string the url where the user is redirected to verify identity. usage • if the user is already registered to confirm identity using a time-based one-time password (totp), then the user is redirected to the one-time password identity verification flow and asked to provide a code. • if the user isn’t registered with any verification method (such as one-time password or salesforce authenticator version 2 or later), the user is prompted to download and verify identity using salesforce authenticator. the user can also choose a different verification method. getcurrentsession() returns a map of attributes for the current session. signature public static map<string, string> getcurrentsession() 156apex reference guide sessionmanagement class return value type: map<string, string> usage the map includes a parentid value, which is the 18-character id for the parent session, if one exists (for example, if the current session is for a canvas app). if the current session doesn’t have a parent, this value is null. the map also includes the logouturl assigned to the current session. if you create an apex test method that calls this method, the test fails with an error such as, “unexpected exception: current session unavailable." an error occurs because there isn’t a session in the context through which the test is being run. when a session is reused, salesforce updates the loginhistoryid with the value from the most recent login. example the following example shows the name-value pairs in a map returned by getcurrentsession(). note that usersid includes an “s” in the name to match the name of the corresponding field in the authsession object. { sessionid=0ak###############, usertype=standard, parentid=0ak###############, numsecondsvalid=7200, logintype=saml idp initiated sso, logindomain=null, loginhistoryid=0ya###############, username=user@domain.com, createddate=wed jul 30 19:09:29 gmt 2014, sessiontype=visualforce, lastmodifieddate=wed jul 30 19:09:
16 gmt 2014, logouturl=https://google.com, sessionsecuritylevel=standard, usersid=005###############, sourceip=1.1.1.1 } getlightninglogineligibility(userid) returns the eligibility status for a user who’s logging in with lightning login when you set up your org with my domain and use the login discovery page type. use this method to redirect the user to a custom login flow. for example, use after a login attempt to redirect the user to password flow if the user is ineligible for lightning login. signature public static auth.lightninglogineligibility getlightninglogineligibility(id userid) parameters userid type: id id of the user who is logging in. 157apex reference guide sessionmanagement class return value type: auth.lightninglogineligibility returns the current eligibility status. example auth.lightninglogineligibility eligibility = auth.sessionmanagement.getlightninglogineligibility(id); if (eligibility == auth.lightninglogineligibility.eligible) { // success } getqrcode() returns a map containing a url to a quick response (qr) code and a time-based one-time password (totp) shared secret to configure authenticator apps or devices for multi-factor authentication (mfa). signature public static map<string, string> getqrcode() return value type: map<string, string> usage the qr code encodes the returned secret as well as the current user's username. the keys are qrcodeurl and secret. calling this method does not change any state for the user, nor does it read any state from the user. this method returns a brand new secret every time it is called, does not save that secret anywhere, and does not validate the totp token. the admin must explicitly save the values for the user after verifying a totp token with the secret. the secret is a base32-encoded string of a 20-byte shared key. example the following is an example of how to request the qr code. public string getgetqrcode() { return getqrcode(); } public string getqrcode() { map<string, string> coderesult = auth.sessionmanagement.getqrcode(); string result = 'url: '+coderesult.get('qrcodeurl') + ' secret: ' + coderesult.get('secret'); return result; } 158apex reference guide sessionmanagement class the following is an example of a returned map. {qrcodeurl=https://www.salesforce.com/secur/qrcode?w=200&h=200&t=tf&u=user%0000000000.com&s=aaaaa7b5bbbb5aaaaaaa66bbbb, secret=aaaaa7b5aaaaaa5bbbbbbbbb66aaa} getrequiredsessionlevelforprofile(profileid) indicates the required login security session level for the given profile. signature public static auth.sessionlevel getrequiredsessionlevelforprofile(string profileid) parameters profileid type: string the 15-character profile id. return value type: auth.sessionlevel the session security level required at login for the profile with the id profileid. you can customize the assignment of each level in session settings. for example, you can set the high assurance level to apply only to users who authenticated with multi-factor authentication (mfa) or through a specific identity provider. ignoreforconcurrentsessionlimit(sessions) this method is reserved for internal salesforce use. signature public static map<string,string> ignoreforconcurrentsessionlimit(object sessions) parameters sessions type: object return value type: map<string, string> inorgnetworkrange(ipaddress) indicates whether the given ip address is within the organization's trusted ip range according to the organization's network access settings. 159apex reference guide sessionmanagement class signature public static boolean inorgnetworkrange(string ipaddress) parameters ipaddress type: string the ip address to validate. return value type: boolean usage if a trusted ip range is not defined, this returns false, and throws an exception if the ip address is not valid. trusted ip range exists? user is in the trusted ip range? return value yes yes true yes no false no n/a false
isipallowedforprofile(profileid, ipaddress) indicates whether the given ip address is within the trusted ip range for the given profile. signature public static boolean isipallowedforprofile(string profileid, string ipaddress) parameters profileid type: string the 15-character alphanumeric string for the current user’s profile id. ipaddress type: string the ip address to validate. return value type: boolean usage if a trusted ip range is not defined, this returns true, and throws an exception if the ip address is not valid or if the profile id is not valid. 160apex reference guide sessionmanagement class trusted ip range exists? user is in the trusted ip range? return value yes yes true yes no false no n/a true setsessionlevel(level) sets the user's current session security level. signature public static void setsessionlevel(auth.sessionlevel level) parameters level type: auth.sessionlevel the session security level to assign to the user. the meaning of each level can be customized in the session settings for each organization, such as setting the high assurance level to apply only to users who authenticated with multi-factor authentication (mfa) or through a specific identity provider. return value type: void usage this setting affects the session level of all sessions associated with the current session, such as visualforce or ui access. if you create an apex test method that calls this method, the test fails with an error such as, “unexpected exception: current session unavailable." an error occurs because there isn’t a session in the context through which the test is being run. example the following is an example class for setting the session level. public class raisesessionlevel{ public void setlevelhigh() { auth.sessionmanagement.setsessionlevel(auth.sessionlevel.high_assurance); } public void setlevelstandard() { auth.sessionmanagement.setsessionlevel(auth.sessionlevel.standard); } } validatetotptokenforkey(sharedkey, totpcode) deprecated. use validatetotptokenforkey(totpsharedkey, totpcode, description) instead. 161apex reference guide sessionmanagement class signature public static boolean validatetotptokenforkey(string sharedkey, string totpcode) parameters sharedkey type: string the shared (secret) key. the sharedkey must be a base32-encoded string of a 20-byte shared key. totpcode type: string the time-based one-time password (totp) code to validate. return value type: boolean usage if the key is invalid or doesn’t exist, this method throws an invalid parameter value exception or a no data found exception, respectively. if the current user exceeds the maximum of 10 token validation attempts, this method throws a security exception. validatetotptokenforkey(totpsharedkey, totpcode, description) indicates whether a time-based one-time password (totp) code (token) is valid for the given shared key. signature public static boolean validatetotptokenforkey(string totpsharedkey, string totpcode, string description) parameters totpsharedkey type: string the shared (secret) key. the totpsharedkey must be a base32-encoded string of a 20-byte shared key. totpcode type: string the time-based one-time password (totp) code to validate. description type: string the custom description that describes the activity requiring identity verification; for example, “complete purchase and check out”. in the setup user interface, this text is shown in the activity message column of identity verification history. the description must be 128 characters or fewer. if you provide a value that’s longer, it’s truncated to 128 characters. return value type: boolean 162apex reference guide sessionmanagement class usage if the key is invalid or doesn’t exist, this method throws an invalid parameter value exception or a no data found exception, respectively. if the current user exceeds the maximum of 10 token validation attempts, this method throws a security exception. validatetotptokenforuser(totpcode) deprecated. use validatetotptokenforuser(totpcode, description) instead. signature public static boolean validatetotptokenforuser
(string totpcode) parameters totpcode type: string the time-based one-time password (totp) code to validate. return value type: boolean usage if the current user does not have a totp code, this method throws an exception. if the current user has attempted too many validations, this method throws an exception. validatetotptokenforuser(totpcode, description) indicates whether a time-based one-time password (totp) code (token) is valid for the current user. signature public static boolean validatetotptokenforuser(string totpcode, string description) parameters totpcode type: string the time-based one-time password (totp) code to validate. description type: string the custom description that describes the activity requiring identity verification; for example, “complete purchase and check out”. this text appears to users when they verify their identity in salesforce and, if they use salesforce authenticator version 2 or later, in the salesforce authenticator mobile app. in addition, in the setup user interface, this text is shown in the activity message column of identity verification history. the description must be 128 characters or fewer. if you provide a value that’s longer, it’s truncated to 128 characters. 163apex reference guide sessionlevel enum return value type: boolean usage if the current user does not have a totp code, or if the current user has attempted too many validations, this method throws an exception. verifydeviceflow(usercode, starturl) verifies the user code entered during the device authentication flow and redirects users to the oauth approval page. if users aren’t logged in, they must log in. after successful login, users are prompted to allow the device to access salesforce data. signature public static system.pagereference verifydeviceflow(string usercode, string starturl) parameters usercode type: string human-readable user code provided to the user by salesforce. the user must enter this code at the verification url to approve device access to salesforce data. starturl type: string the url for the page that the user is redirected to after successful login and approval of the device to access salesforce data. if you don’t specify a start url, the user is redirected to the home page. return value type:system.pagereference usage include this method in the apex controller when creating a custom visualforce user code verification page for the oauth 2.0 device authentication flow. this method verifies the user code, prompts the user to log in as needed, and prompts the user to allow the device access to salesforce data. upon successful verification and authentication, the user is redirected to the page defined by the start url. sessionlevel enum an auth.sessionlevel enum value is used by the sessionmanagement.setsessionlevel method. namespace auth 164apex reference guide userdata class enum values value description low the user’s security level for the current session meets the lowest requirements. note: this low level is not available, nor used, in the salesforce ui. user sessions through the salesforce ui are either standard or high assurance. you can set this level using the api, but users assigned this level will experience unpredictable and reduced functionality in their salesforce organization. standard the user’s security level for the current session meets the standard requirements set in the current organization session security levels. high_assurance the user’s security level for the current session meets the high assurance requirements set in the current organization session security levels. usage with session-level security, you control user access to features that support it, such as connected apps and reporting. for example, you can customize an organization’s session settings to require users to log in with multi-factor authentication (mfa) to get a high assurance session. then, you can restrict access to a specific connected app by requiring a high assurance session level in the settings for the connected app. userdata class stores user information for auth.registrationhandler. namespace auth in this section: userdata constructors userdata properties userdata constructors the following are constructors for userdata. in this section: userdata(identifier, firstname, lastname, fullname, email, link, username, locale, provider, siteloginurl, attributemap) creates a new instance of the auth
.userdata class using the specified arguments. 165apex reference guide userdata class userdata(identifier, firstname, lastname, fullname, email, link, username, locale, provider, siteloginurl, attributemap) creates a new instance of the auth.userdata class using the specified arguments. signature public userdata(string identifier, string firstname, string lastname, string fullname, string email, string link, string username, string locale, string provider, string siteloginurl, map<string,string> attributemap) parameters identifier type: string an identifier from the third party for the authenticated user, such as the facebook user number or the salesforce user id. firstname type: string the first name of the authenticated user, according to the third party. lastname type: string the last name of the authenticated user, according to the third party. fullname type: string the full name of the authenticated user, according to the third party. email type: string the email address of the authenticated user, according to the third party. link type: string a stable link for the authenticated user such as https://www.facebook.com/myusername. username type: string the username of the authenticated user in the third party. locale type: string the standard locale string for the authenticated user. provider type: string the service used to log in, such as facebook or janrain. siteloginurl type: string the site login page url passed in if used with a site; null otherwise. 166apex reference guide userdata class attributemap type: map<string, string> a map of data from the third party, in case the handler has to access non-standard values. for example, when using janrain as a provider, the fields janrain returns in its accesscredentials dictionary are placed into the attributemap. these fields vary by provider. userdata properties the following are properties for userdata. in this section: identifier an identifier from the third party for the authenticated user, such as the facebook user number or the salesforce user id. firstname the first name of the authenticated user, according to the third party. lastname the last name of the authenticated user, according to the third party. fullname the full name of the authenticated user, according to the third party. email the email address of the authenticated user, according to the third party. link a stable link for the authenticated user such as https://www.facebook.com/myusername. username the username of the authenticated user in the third party. locale the standard locale string for the authenticated user. provider the service used to log in, such as facebook or janrain. siteloginurl the site login page url passed in if used with a site; null otherwise. attributemap a map of data from the third party, in case the handler has to access non-standard values. for example, when using janrain as a provider, the fields janrain returns in its accesscredentials dictionary are placed into the attributemap. these fields vary by provider. identifier an identifier from the third party for the authenticated user, such as the facebook user number or the salesforce user id. signature public string identifier {get; set;} 167apex reference guide userdata class property value type: string firstname the first name of the authenticated user, according to the third party. signature public string firstname {get; set;} property value type: string lastname the last name of the authenticated user, according to the third party. signature public string lastname {get; set;} property value type: string fullname the full name of the authenticated user, according to the third party. signature public string fullname {get; set;} property value type: string email the email address of the authenticated user, according to the third party. signature public string email {get; set;} property value type: string 168apex reference guide userdata class link a stable link for the authenticated user such as https://www.facebook.com/myusername. signature public string link {get; set;} property value type: string username the username of the authenticated user in the third party. signature public string username {get; set;} property value type: string locale the standard locale string for the authenticated user. signature public string
locale {get; set;} property value type: string provider the service used to log in, such as facebook or janrain. signature public string provider {get; set;} property value type: string siteloginurl the site login page url passed in if used with a site; null otherwise. 169apex reference guide verificationmethod enum signature public string siteloginurl {get; set;} property value type: string attributemap a map of data from the third party, in case the handler has to access non-standard values. for example, when using janrain as a provider, the fields janrain returns in its accesscredentials dictionary are placed into the attributemap. these fields vary by provider. signature public map<string, string> attributemap {get; set;} property value type: map<string, string> verificationmethod enum contains the different ways users can identify themselves when logging in. you can use it to implement mobile-centric passwordless login pages and to self-register (and deregister) verification methods. usage the enum value is an argument in system.site.passwordlesslogin, system.usermanagement.registerverificationmethod, and system.usermanagement.deregisterverificationmethod on page 3504 methods. the value indicates the method used to verify a user’s identity. enum values the following are the values of the auth.verificationmethod enum. value description built_in_authenticator identity verified with a built-in authenticator. email identity verified with a verification code sent in an email message. password identity verified with a password. salesforce_authenticator identity verified by salesforce authenticator. security_key identity verified by a webauthn-compatible physical security key. includes all security keys registered or used after summer ’22. sms identity verified with a verification code sent via sms message. totp identity verified with a time-based one-time password (totp). 170apex reference guide verificationpolicy enum value description u2f identity verified by a u2f physical security key, such as a yubikey. note: for u2f security keys registered or used after summer ’22, use security_key instead. verificationpolicy enum the auth.verificationpolicy enum contains an identity verification policy value used by the sessionmanagement.generateverificationurl method. usage the enum value is an argument in the sessionmanagement.generateverificationurl method. the value indicates the session security policy required to initiate identity verification for the user’s session. enum values the auth.verificationpolicy enum has this value. value description high_assurance the security level for the user’s current session must be high assurance. verificationresult class contains the result of a verification challenge that you invoke when you create your own verify page. the challenge can be initiated by either the system.usermanagement.verifypasswordlesslogin or system.usermanagement.verifyselfregistration method. namespace auth usage when users sign up for or log in to your experience cloud site with an email address or phone number, salesforce sends them a verification code. at the same time, salesforce generates the verify page for users to enter the code to verify their identity. you can replace the salesforce-generated verify page with one that you create with visualforce. then invoke the verification challenge and, if the verification code is entered correctly, log in the user. for sign-up, you use the system.usermanagement.verifyselfregistration method. for passwordless login, you use the system.usermanagement.verifypasswordlesslogin method. the methods return the verification result, which contains the message displayed as a result of the challenge. this message also indicates whether the challenge is successful and where to direct the user when the verification code is entered correctly. 171apex reference guide verificationresult class example this code contains the result of a verification challenge that registers a new user. string id = system.usermanagement.initselfregistration (auth.verificationmethod.sms, user); auth.verificationresult res = system.usermanagement.verifyselfregistration (auth.verificationmethod.sms, id, ‘123456’, null); if(res.success == true){ //redirect } in this section: verificationresult constructor verificationresult properties verificationresult method verificationresult constructor
verificationresult has the following constructor. in this section: verificationresult(redirect, success, message) creates an instance of the verificationresult class that contains the verification result from system.usermanagement.verifyselfregistration. verificationresult(redirect, success, message) creates an instance of the verificationresult class that contains the verification result from system.usermanagement.verifyselfregistration. signature public verificationresult(system.pagereference redirect, boolean success, string message) parameters redirect type: system.pagereferencesystem.pagereference where user is directed upon successful verification. success type: boolean indicates whether verification succeeded. message type: string message that displays as a result of a verification challenge. 172apex reference guide verificationresult class verificationresult properties the following are properties for verificationresult. in this section: message message that displays as a result of a verification challenge. success if the identity verification is successful. other values are failure, pending, rate_limited, or failure_report. redirect where the user is directed after entering the verification code successfully, for example, the experience cloud site’s home page or location specified by the start url. success the verification challenge is successful. message message that displays as a result of a verification challenge. success if the identity verification is successful. other values are failure, pending, rate_limited, or failure_report. signature public string message {get; set;} property value type: string redirect where the user is directed after entering the verification code successfully, for example, the experience cloud site’s home page or location specified by the start url. signature public system.pagereference redirect {get; set;} property value type: system.pagereferencesystem.pagereference success the verification challenge is successful. signature public boolean success {get; set;} 173apex reference guide auth exceptions property value type: boolean verificationresult method verificationresult has the following method. in this section: clone() duplicates the auth.verificationresult object. clone() duplicates the auth.verificationresult object. signature public object clone() return value type: verificationresult auth exceptions the auth namespace contains some exception classes. all exception classes support built-in methods for returning the error message and exception type. see exception class and built-in exceptions. the auth namespace contains the following exception. exception description auth. throw this exception to indicate that an error occurred when using the auth provider plug-in. authproviderpluginexception use to display a custom error message to the user. to get the error message and write it to debug log, use the string getmessage(). auth.connectedappplugin throw this exception to indicate that an error occurred while running the custom behavior for exception a connected app. to get the error message and write it to debug log, use the string getmessage(). auth.discoverycustomerrorexception throw this exception to customize error messages that appear on discovery logins and configurable self-registration pages. an error message can have up to 200 characters. use custom error exceptions to localize error messages. include this exception in: • auth.mydomainlogindiscoveryhandler to show a custom error message on the my domain login page 174apex reference guide auth exceptions exception description • auth.logindiscoveryhandler to show an error message on the experience cloud site login page • auth.configurableselfreghandler to show an error message on the experience cloud site self-registration verify page the verify page shows up if you configured self-registration with either an email or text message verification method. if you didn’t set up sign-up with a verification method, the error message appears on the self-registration page. to get the error message and write it to debug log, use the string getmessage(). auth.jwtbearertokenexchange. throw this exception to indicate a problem with the response from the token endpoint in the jwtbearertokenexchangeexception jwtbearertokenexchange class. this exception occurs during the oauth 2.0 jwt bearer token flow when the http response: • fails to return an access token • isn’t in json format • returns a response code other than a 200 “ok” success code to get the error message and write it to debug log, use the string getmessage