Skip to content

Commit 34d32b9

Browse files
authored
feat(salesforce): add Tooling API schema tools (custom field/object) + metadata query (#5209)
* feat(salesforce): add Tooling API schema tools (custom field/object) + metadata query Add salesforce_create_custom_field, salesforce_update_custom_field, salesforce_delete_custom_field, salesforce_create_custom_object, and salesforce_tooling_query so the connector can make schema/metadata changes (e.g. create a custom field on Account). Previously the integration only did record CRUD via the REST Data API. Existing `api` OAuth scope covers the Tooling API; metadata creation is profile-permission gated, so no scope change. Also: fix Opportunity closeDate being wrongly required on update_opportunity, make list_reports/list_dashboards descriptions honest (recently-viewed scope), and document run_report's includeDetails default. * improvement(salesforce): non-destructive custom field update + align metadata param types - update_custom_field now does a read-modify-write (GET existing Metadata, overlay only provided changes, PATCH) so omitted properties are preserved instead of being reset by the Tooling API's full-metadata PATCH; no more fabricated label or injected create-time defaults on update - fieldType is now optional on update (kept from the existing field unless changed) - widen length/precision/scale/visibleLines param types to number | string to match the tool param configs (type: number) * improvement(salesforce): preserve picklist values and clear stale metadata on field type change - custom field update now unions provided picklist values with the field's existing values instead of replacing the whole valueSet (no data loss) - when fieldType changes on update, drop the prior type's type-specific metadata (length/precision/scale/visibleLines/valueSet/defaultValue/unique/ externalId) and backfill the new type's required defaults * improvement(salesforce): scope custom field update to attributes, never the type update_custom_field no longer changes a field's data type: Salesforce treats a type change as a separate conversion operation, and a stale forwarded fieldType could otherwise trigger an unintended destructive migration. The merge keeps the field's existing type and overlays only the other provided properties, dropping the type-change/stale-metadata-stripping logic entirely.
1 parent e748a64 commit 34d32b9

15 files changed

Lines changed: 1585 additions & 17 deletions

File tree

apps/docs/content/docs/en/integrations/salesforce.mdx

Lines changed: 147 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The Salesforce tool is ideal for workflows where your agents need to streamline
2727

2828
## Usage Instructions
2929

30-
Integrate Salesforce into your workflow. Manage accounts, contacts, leads, opportunities, cases, and tasks with powerful automation capabilities.
30+
Integrate Salesforce into your workflow. Manage accounts, contacts, leads, opportunities, cases, and tasks, run reports and SOQL queries, and manage org schema by creating custom fields and objects via the Tooling API.
3131

3232

3333

@@ -717,7 +717,7 @@ Delete a task
717717

718718
### `salesforce_list_reports`
719719

720-
Get a list of reports accessible by the current user
720+
Get a list of up to 200 recently viewed reports for the current user
721721

722722
#### Input
723723

@@ -814,7 +814,7 @@ Get a list of available report types
814814

815815
### `salesforce_list_dashboards`
816816

817-
Get a list of dashboards accessible by the current user
817+
Get a list of recently used dashboards for the current user
818818

819819
#### Input
820820

@@ -1029,6 +1029,150 @@ Get a list of all available Salesforce objects
10291029
|`totalReturned` | number | Number of objects returned |
10301030
|`success` | boolean | Salesforce operation success |
10311031

1032+
### `salesforce_create_custom_field`
1033+
1034+
Create a custom field on a Salesforce object (e.g., Account) using the Tooling API
1035+
1036+
#### Input
1037+
1038+
| Parameter | Type | Required | Description |
1039+
| --------- | ---- | -------- | ----------- |
1040+
| `idToken` | string | No | No description |
1041+
| `instanceUrl` | string | No | No description |
1042+
| `objectName` | string | Yes | API name of the object to add the field to \(e.g., Account, Contact, Lead, MyObject__c\) |
1043+
| `fieldName` | string | Yes | API name of the new field; the __c suffix is added automatically \(e.g., Region\) |
1044+
| `label` | string | No | Display label shown in the UI \(defaults to the field name when omitted\) |
1045+
| `fieldType` | string | Yes | Field data type: Text, TextArea, LongTextArea, Html, Number, Currency, Percent, Checkbox, Date, DateTime, Time, Phone, Email, Url, Picklist, or MultiselectPicklist |
1046+
| `length` | number | No | Maximum length for Text \(1-255\), LongTextArea, Html, or MultiselectPicklist fields |
1047+
| `precision` | number | No | Total number of digits for Number, Currency, or Percent fields \(1-18\) |
1048+
| `scale` | number | No | Number of digits to the right of the decimal for numeric fields |
1049+
| `visibleLines` | number | No | Number of visible lines for LongTextArea, Html, or MultiselectPicklist fields |
1050+
| `required` | boolean | No | Whether the field is required on record create/edit |
1051+
| `unique` | boolean | No | Whether the field enforces unique values |
1052+
| `externalId` | boolean | No | Whether the field is an external ID \(for Text, Number, or Email fields\) |
1053+
| `defaultValue` | string | No | Default value; for Checkbox fields use true or false |
1054+
| `description` | string | No | Internal description of the field |
1055+
| `inlineHelpText` | string | No | Help text shown next to the field in the UI |
1056+
| `picklistValues` | string | No | Comma-separated values for Picklist or MultiselectPicklist fields |
1057+
1058+
#### Output
1059+
1060+
| Parameter | Type | Description |
1061+
| --------- | ---- | ----------- |
1062+
| `success` | boolean | Operation success status |
1063+
| `output` | object | Created custom field metadata |
1064+
|`id` | string | Tooling API Id of the newly created custom field |
1065+
|`fullName` | string | Full API name of the field, including object \(e.g., Account.Region__c\) |
1066+
|`success` | boolean | Whether the create operation was successful |
1067+
|`created` | boolean | Whether the field was created \(always true on success\) |
1068+
1069+
### `salesforce_update_custom_field`
1070+
1071+
Update an existing custom field on a Salesforce object using the Tooling API
1072+
1073+
#### Input
1074+
1075+
| Parameter | Type | Required | Description |
1076+
| --------- | ---- | -------- | ----------- |
1077+
| `idToken` | string | No | No description |
1078+
| `instanceUrl` | string | No | No description |
1079+
| `fieldId` | string | Yes | Tooling API Id of the custom field to update \(find it via the Tooling Query tool\) |
1080+
| `label` | string | No | Display label shown in the UI |
1081+
| `length` | number | No | Maximum length for Text, LongTextArea, Html, or MultiselectPicklist fields |
1082+
| `precision` | number | No | Total number of digits for Number, Currency, or Percent fields |
1083+
| `scale` | number | No | Number of digits to the right of the decimal for numeric fields |
1084+
| `visibleLines` | number | No | Number of visible lines for LongTextArea, Html, or MultiselectPicklist fields |
1085+
| `required` | boolean | No | Whether the field is required on record create/edit |
1086+
| `unique` | boolean | No | Whether the field enforces unique values |
1087+
| `externalId` | boolean | No | Whether the field is an external ID |
1088+
| `defaultValue` | string | No | Default value; for Checkbox fields use true or false |
1089+
| `description` | string | No | Internal description of the field |
1090+
| `inlineHelpText` | string | No | Help text shown next to the field in the UI |
1091+
| `picklistValues` | string | No | Comma-separated values to add to a Picklist or MultiselectPicklist field \(existing values are kept\) |
1092+
1093+
#### Output
1094+
1095+
| Parameter | Type | Description |
1096+
| --------- | ---- | ----------- |
1097+
| `success` | boolean | Operation success status |
1098+
| `output` | object | Updated custom field metadata |
1099+
|`id` | string | Tooling API Id of the updated custom field |
1100+
|`updated` | boolean | Whether the field was updated \(always true on success\) |
1101+
1102+
### `salesforce_delete_custom_field`
1103+
1104+
Delete a custom field from a Salesforce object using the Tooling API
1105+
1106+
#### Input
1107+
1108+
| Parameter | Type | Required | Description |
1109+
| --------- | ---- | -------- | ----------- |
1110+
| `idToken` | string | No | No description |
1111+
| `instanceUrl` | string | No | No description |
1112+
| `fieldId` | string | Yes | Tooling API Id of the custom field to delete \(find it via the Tooling Query tool\) |
1113+
1114+
#### Output
1115+
1116+
| Parameter | Type | Description |
1117+
| --------- | ---- | ----------- |
1118+
| `success` | boolean | Operation success status |
1119+
| `output` | object | Deleted custom field metadata |
1120+
|`id` | string | Tooling API Id of the deleted custom field |
1121+
|`deleted` | boolean | Whether the field was deleted \(always true on success\) |
1122+
1123+
### `salesforce_create_custom_object`
1124+
1125+
Create a custom object in Salesforce using the Tooling API
1126+
1127+
#### Input
1128+
1129+
| Parameter | Type | Required | Description |
1130+
| --------- | ---- | -------- | ----------- |
1131+
| `idToken` | string | No | No description |
1132+
| `instanceUrl` | string | No | No description |
1133+
| `objectName` | string | Yes | API name of the new object; the __c suffix is added automatically \(e.g., Project\) |
1134+
| `label` | string | Yes | Singular display label for the object \(e.g., Project\) |
1135+
| `pluralLabel` | string | Yes | Plural display label for the object \(e.g., Projects\) |
1136+
| `nameFieldLabel` | string | No | Label for the standard Name field \(defaults to "<label> Name"\) |
1137+
| `description` | string | No | Internal description of the object |
1138+
| `sharingModel` | string | No | Org-wide sharing model: ReadWrite, Read, Private, or ControlledByParent \(default ReadWrite\) |
1139+
1140+
#### Output
1141+
1142+
| Parameter | Type | Description |
1143+
| --------- | ---- | ----------- |
1144+
| `success` | boolean | Operation success status |
1145+
| `output` | object | Created custom object metadata |
1146+
|`id` | string | Tooling API Id of the newly created custom object |
1147+
|`fullName` | string | Full API name of the object \(e.g., Project__c\) |
1148+
|`success` | boolean | Whether the create operation was successful |
1149+
|`created` | boolean | Whether the object was created \(always true on success\) |
1150+
1151+
### `salesforce_tooling_query`
1152+
1153+
Execute a SOQL query against the Tooling API to inspect metadata objects
1154+
1155+
#### Input
1156+
1157+
| Parameter | Type | Required | Description |
1158+
| --------- | ---- | -------- | ----------- |
1159+
| `idToken` | string | No | No description |
1160+
| `instanceUrl` | string | No | No description |
1161+
| `query` | string | Yes | Tooling SOQL query \(e.g., SELECT Id, DeveloperName FROM CustomField WHERE TableEnumOrId = 'Account'\) |
1162+
1163+
#### Output
1164+
1165+
| Parameter | Type | Description |
1166+
| --------- | ---- | ----------- |
1167+
| `success` | boolean | Operation success status |
1168+
| `output` | object | Tooling query results |
1169+
|`records` | array | Array of Tooling API records matching the query |
1170+
|`query` | string | The executed Tooling SOQL query |
1171+
|`metadata` | object | Response metadata |
1172+
|`totalReturned` | number | Number of records returned in this response |
1173+
|`hasMore` | boolean | Whether more records exist \(inverse of done\) |
1174+
|`success` | boolean | Salesforce operation success |
1175+
10321176

10331177

10341178
## Triggers

0 commit comments

Comments
 (0)