Newer Version Available

This content describes an older version of this product. View Latest

Update Multiple Records with Fewer Round-Trips

Use a PATCH request with sObject Collections to update multiple records, returning a list of SaveResult objects. You can choose whether to roll back the entire request when an error occurs.

Request Syntax

PATCH /vXX.X/tooling/composite/sobjects

Parameters

Parameter Description
allOrNone Optional. Indicates whether to roll back the entire request when the update of any object fails (true) or to continue with the independent update of other objects in the request. The default is false.
records Required. A list of sObjects. In a POST request using sObject Collections, set the type attribute for each object. You can set either the id field or, if available, the FullName field for any object.

Usage Guidelines

  • The list for FlexiPage can contain up to 200 objects. As support is added for other Tooling API objects, the maximum number of objects might be different for each.
  • The list can contain objects of different types, including custom objects.
  • Each object must contain an attributes map. The map must contain a value for type.
  • If the object has a Metadata field, you can specify either an id field with a valid ID value or the FullName field. If the object doesn’t have a Metadata field, the id field with a valid ID value is required.
  • Objects are updated in the order they’re listed. The SaveResult objects are returned in the order in which the update requests were specified.
  • If the request body includes objects of more than one type, they are processed as chunks. For example, if the incoming objects are {objectA1, objectA2, objectB1, objectA3}, the request is processed in three chunks: {{objectA1, objectA2}, {objectB1}, {objectA3}}. A single request can process up to 10 chunks.
  • Although SObject Collections is also supported in SOAP API, you can’t use SOAP API objects in a Tooling API SObject Collections call.

Checking for Errors

  • If the request isn’t well formed, the API returns a 400 Bad Request HTTP Status. Fix the syntax of the request and try again.
  • If the request is well formed, the API returns a 200 OK HTTP Status. If an item was processed successfully, the success flag shows for that item. Error information is returned in the errors array.

Request Body Example

1PATCH /tooling/composite/sobjects
2  {
3  "allOrNone": false,
4  "records": [
5    { 
6      "attributes" : {"type" : "FlexiPage"},
7      "metadata": {
8        "template": {
9          "name": "flexipage:defaultAppHomeTemplate"
10        },
11        "masterLabel": "FlexiPageLabel",
12        "flexiPageRegions": [
13          {
14            "componentInstances": [
15              {
16                "componentInstanceProperties": [
17                  {
18                    "name": "entityName",
19                    "value": "Account"
20                  },
21                  {
22                    "name": "filterName",
23                    "value": "AllAccounts"
24                  }
25                ],
26                "componentName": "flexipage:filterListCard"
27              }
28            ],
29            "name": "main",
30            "type": "Region"
31          }
32        ],
33        "description": "Initial flexipage description updated",
34        "type": "AppPage"
35      },
36      "fullname": "FlexiPageFullName"
37    },
38    { 
39      "attributes" : {"type" : "FlexiPage"},
40      "metadata": {
41        "template": {
42          "name": "flexipage:defaultAppHomeTemplate"
43        },
44        "masterLabel": "FlexiPageLabel",
45        "flexiPageRegions": [
46          {
47            "componentInstances": [
48              {
49                "componentInstanceProperties": [
50                  {
51                    "name": "entityName",
52                    "value": "Account"
53                  },
54                  {
55                    "name": "filterName",
56                    "value": "AllAccounts"
57                  }
58                ],
59                "componentName": "flexipage:filterListCard"
60              }
61            ],
62            "name": "main",
63            "type": "Region"
64          }
65        ],
66        "description": "Initial flexipage description updated",
67        "type": "AppPage"
68      },
69      "fullname": "FlexiPageFullNameOne"
70    }
71  ]
72}

Response Body Examples

This example shows a response when all the items were processed successfully.
1HTTP/1.1 200 OK
2
3[
4   {
5      "id" : "001RM000003oCprYAE",
6      "success" : true,
7      "errors" : [ ]
8   },
9   {
10      "id" : "003RM0000068og4YAA",
11      "success" : true,
12      "errors" : [ ]
13   }
14]
This example shows a response when some items caused errors and allOrNone is false.
1HTTP/1.1 200 OK
2[
3  {
4    "id": "001RM000003oCprYAE",
5    "success": true,
6    "errors": [
7      
8    ]
9  },
10  {
11    "success": false,
12    "errors": [
13      {
14        "statusCode": "MALFORMED_ID",
15        "message": "Duplicate Fullname",
16        "fields": [
17          "Id"
18        ]
19      }
20    ]
21  }
22]
This example shows a response when some items caused errors and allOrNone is true.
1HTTP/1.1 200 OK
2[
3  {
4    "id" : "001RM000003oCprYAE",
5    "success" : false,
6    "errors" : [
7      {
8      "statusCode" : "ALL_OR_NONE_OPERATION_ROLLED_BACK",
9      "message" : "Record rolled back because not all records were valid and the request was using AllOrNone header",
10      "fields" : [ ]
11      }
12    ]
13  },
14  {
15    "success" : false,
16    "errors" : [
17      {
18        "statusCode" : "MALFORMED_ID",
19        "message" : "Duplicate Fullname",
20        "fields" : [
21          "Id"
22        ]
23      }
24    ]
25  }
26]