diff --git a/apps/docs/content/docs/en/integrations/salesforce.mdx b/apps/docs/content/docs/en/integrations/salesforce.mdx index 1125dc36cdd..76e5729536c 100644 --- a/apps/docs/content/docs/en/integrations/salesforce.mdx +++ b/apps/docs/content/docs/en/integrations/salesforce.mdx @@ -27,7 +27,7 @@ The Salesforce tool is ideal for workflows where your agents need to streamline ## Usage Instructions -Integrate Salesforce into your workflow. Manage accounts, contacts, leads, opportunities, cases, and tasks with powerful automation capabilities. +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. @@ -717,7 +717,7 @@ Delete a task ### `salesforce_list_reports` -Get a list of reports accessible by the current user +Get a list of up to 200 recently viewed reports for the current user #### Input @@ -814,7 +814,7 @@ Get a list of available report types ### `salesforce_list_dashboards` -Get a list of dashboards accessible by the current user +Get a list of recently used dashboards for the current user #### Input @@ -1029,6 +1029,150 @@ Get a list of all available Salesforce objects | ↳ `totalReturned` | number | Number of objects returned | | ↳ `success` | boolean | Salesforce operation success | +### `salesforce_create_custom_field` + +Create a custom field on a Salesforce object (e.g., Account) using the Tooling API + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `idToken` | string | No | No description | +| `instanceUrl` | string | No | No description | +| `objectName` | string | Yes | API name of the object to add the field to \(e.g., Account, Contact, Lead, MyObject__c\) | +| `fieldName` | string | Yes | API name of the new field; the __c suffix is added automatically \(e.g., Region\) | +| `label` | string | No | Display label shown in the UI \(defaults to the field name when omitted\) | +| `fieldType` | string | Yes | Field data type: Text, TextArea, LongTextArea, Html, Number, Currency, Percent, Checkbox, Date, DateTime, Time, Phone, Email, Url, Picklist, or MultiselectPicklist | +| `length` | number | No | Maximum length for Text \(1-255\), LongTextArea, Html, or MultiselectPicklist fields | +| `precision` | number | No | Total number of digits for Number, Currency, or Percent fields \(1-18\) | +| `scale` | number | No | Number of digits to the right of the decimal for numeric fields | +| `visibleLines` | number | No | Number of visible lines for LongTextArea, Html, or MultiselectPicklist fields | +| `required` | boolean | No | Whether the field is required on record create/edit | +| `unique` | boolean | No | Whether the field enforces unique values | +| `externalId` | boolean | No | Whether the field is an external ID \(for Text, Number, or Email fields\) | +| `defaultValue` | string | No | Default value; for Checkbox fields use true or false | +| `description` | string | No | Internal description of the field | +| `inlineHelpText` | string | No | Help text shown next to the field in the UI | +| `picklistValues` | string | No | Comma-separated values for Picklist or MultiselectPicklist fields | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Operation success status | +| `output` | object | Created custom field metadata | +| ↳ `id` | string | Tooling API Id of the newly created custom field | +| ↳ `fullName` | string | Full API name of the field, including object \(e.g., Account.Region__c\) | +| ↳ `success` | boolean | Whether the create operation was successful | +| ↳ `created` | boolean | Whether the field was created \(always true on success\) | + +### `salesforce_update_custom_field` + +Update an existing custom field on a Salesforce object using the Tooling API + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `idToken` | string | No | No description | +| `instanceUrl` | string | No | No description | +| `fieldId` | string | Yes | Tooling API Id of the custom field to update \(find it via the Tooling Query tool\) | +| `label` | string | No | Display label shown in the UI | +| `length` | number | No | Maximum length for Text, LongTextArea, Html, or MultiselectPicklist fields | +| `precision` | number | No | Total number of digits for Number, Currency, or Percent fields | +| `scale` | number | No | Number of digits to the right of the decimal for numeric fields | +| `visibleLines` | number | No | Number of visible lines for LongTextArea, Html, or MultiselectPicklist fields | +| `required` | boolean | No | Whether the field is required on record create/edit | +| `unique` | boolean | No | Whether the field enforces unique values | +| `externalId` | boolean | No | Whether the field is an external ID | +| `defaultValue` | string | No | Default value; for Checkbox fields use true or false | +| `description` | string | No | Internal description of the field | +| `inlineHelpText` | string | No | Help text shown next to the field in the UI | +| `picklistValues` | string | No | Comma-separated values to add to a Picklist or MultiselectPicklist field \(existing values are kept\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Operation success status | +| `output` | object | Updated custom field metadata | +| ↳ `id` | string | Tooling API Id of the updated custom field | +| ↳ `updated` | boolean | Whether the field was updated \(always true on success\) | + +### `salesforce_delete_custom_field` + +Delete a custom field from a Salesforce object using the Tooling API + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `idToken` | string | No | No description | +| `instanceUrl` | string | No | No description | +| `fieldId` | string | Yes | Tooling API Id of the custom field to delete \(find it via the Tooling Query tool\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Operation success status | +| `output` | object | Deleted custom field metadata | +| ↳ `id` | string | Tooling API Id of the deleted custom field | +| ↳ `deleted` | boolean | Whether the field was deleted \(always true on success\) | + +### `salesforce_create_custom_object` + +Create a custom object in Salesforce using the Tooling API + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `idToken` | string | No | No description | +| `instanceUrl` | string | No | No description | +| `objectName` | string | Yes | API name of the new object; the __c suffix is added automatically \(e.g., Project\) | +| `label` | string | Yes | Singular display label for the object \(e.g., Project\) | +| `pluralLabel` | string | Yes | Plural display label for the object \(e.g., Projects\) | +| `nameFieldLabel` | string | No | Label for the standard Name field \(defaults to "<label> Name"\) | +| `description` | string | No | Internal description of the object | +| `sharingModel` | string | No | Org-wide sharing model: ReadWrite, Read, Private, or ControlledByParent \(default ReadWrite\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Operation success status | +| `output` | object | Created custom object metadata | +| ↳ `id` | string | Tooling API Id of the newly created custom object | +| ↳ `fullName` | string | Full API name of the object \(e.g., Project__c\) | +| ↳ `success` | boolean | Whether the create operation was successful | +| ↳ `created` | boolean | Whether the object was created \(always true on success\) | + +### `salesforce_tooling_query` + +Execute a SOQL query against the Tooling API to inspect metadata objects + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `idToken` | string | No | No description | +| `instanceUrl` | string | No | No description | +| `query` | string | Yes | Tooling SOQL query \(e.g., SELECT Id, DeveloperName FROM CustomField WHERE TableEnumOrId = 'Account'\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Operation success status | +| `output` | object | Tooling query results | +| ↳ `records` | array | Array of Tooling API records matching the query | +| ↳ `query` | string | The executed Tooling SOQL query | +| ↳ `metadata` | object | Response metadata | +| ↳ `totalReturned` | number | Number of records returned in this response | +| ↳ `hasMore` | boolean | Whether more records exist \(inverse of done\) | +| ↳ `success` | boolean | Salesforce operation success | + ## Triggers diff --git a/apps/sim/blocks/blocks/salesforce.ts b/apps/sim/blocks/blocks/salesforce.ts index 11cbc2b58d1..100ac47cad6 100644 --- a/apps/sim/blocks/blocks/salesforce.ts +++ b/apps/sim/blocks/blocks/salesforce.ts @@ -11,7 +11,7 @@ export const SalesforceBlock: BlockConfig = { description: 'Interact with Salesforce CRM', authMode: AuthMode.OAuth, longDescription: - 'Integrate Salesforce into your workflow. Manage accounts, contacts, leads, opportunities, cases, and tasks with powerful automation capabilities.', + '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.', docsLink: 'https://docs.sim.ai/integrations/salesforce', category: 'tools', integrationType: IntegrationType.Sales, @@ -69,6 +69,11 @@ export const SalesforceBlock: BlockConfig = { { label: 'Get More Query Results', id: 'query_more' }, { label: 'Describe Object', id: 'describe_object' }, { label: 'List Objects', id: 'list_objects' }, + { label: 'Create Custom Field', id: 'create_custom_field' }, + { label: 'Update Custom Field', id: 'update_custom_field' }, + { label: 'Delete Custom Field', id: 'delete_custom_field' }, + { label: 'Create Custom Object', id: 'create_custom_object' }, + { label: 'Run Tooling Query', id: 'tooling_query' }, ], value: () => 'get_accounts', }, @@ -445,7 +450,7 @@ export const SalesforceBlock: BlockConfig = { type: 'short-input', placeholder: 'YYYY-MM-DD (required for create)', condition: { field: 'operation', value: ['create_opportunity', 'update_opportunity'] }, - required: true, + required: { field: 'operation', value: ['create_opportunity'] }, wandConfig: { enabled: true, prompt: `Generate a date in YYYY-MM-DD format based on the user's description. @@ -608,8 +613,8 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n title: 'SOQL Query', type: 'long-input', placeholder: 'SELECT Id, Name FROM Account LIMIT 10', - condition: { field: 'operation', value: ['query'] }, - required: true, + condition: { field: 'operation', value: ['query', 'tooling_query'] }, + required: { field: 'operation', value: ['query', 'tooling_query'] }, }, { id: 'nextRecordsUrl', @@ -624,8 +629,14 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n title: 'Object Name', type: 'short-input', placeholder: 'API name (e.g., Account, Lead, Custom_Object__c)', - condition: { field: 'operation', value: ['describe_object'] }, - required: true, + condition: { + field: 'operation', + value: ['describe_object', 'create_custom_field', 'create_custom_object'], + }, + required: { + field: 'operation', + value: ['describe_object', 'create_custom_field', 'create_custom_object'], + }, }, // Long-input fields at the bottom { @@ -649,9 +660,182 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n 'update_case', 'create_task', 'update_task', + 'create_custom_field', + 'update_custom_field', + 'create_custom_object', ], }, }, + // Schema / metadata fields (Tooling API) + { + id: 'fieldName', + title: 'Field Name', + type: 'short-input', + placeholder: 'API name without __c (e.g., Region)', + condition: { field: 'operation', value: ['create_custom_field'] }, + required: { field: 'operation', value: ['create_custom_field'] }, + }, + { + id: 'fieldId', + title: 'Field ID', + type: 'short-input', + placeholder: 'Tooling API Id (find via Run Tooling Query)', + condition: { field: 'operation', value: ['update_custom_field', 'delete_custom_field'] }, + required: { field: 'operation', value: ['update_custom_field', 'delete_custom_field'] }, + }, + { + id: 'fieldType', + title: 'Field Type', + type: 'dropdown', + options: [ + { label: 'Text', id: 'Text' }, + { label: 'Text Area', id: 'TextArea' }, + { label: 'Text Area (Long)', id: 'LongTextArea' }, + { label: 'Rich Text Area', id: 'Html' }, + { label: 'Number', id: 'Number' }, + { label: 'Currency', id: 'Currency' }, + { label: 'Percent', id: 'Percent' }, + { label: 'Checkbox', id: 'Checkbox' }, + { label: 'Date', id: 'Date' }, + { label: 'Date/Time', id: 'DateTime' }, + { label: 'Time', id: 'Time' }, + { label: 'Phone', id: 'Phone' }, + { label: 'Email', id: 'Email' }, + { label: 'URL', id: 'Url' }, + { label: 'Picklist', id: 'Picklist' }, + { label: 'Picklist (Multi-Select)', id: 'MultiselectPicklist' }, + ], + condition: { field: 'operation', value: ['create_custom_field'] }, + required: { field: 'operation', value: ['create_custom_field'] }, + }, + { + id: 'label', + title: 'Label', + type: 'short-input', + placeholder: 'Display label', + condition: { + field: 'operation', + value: ['create_custom_field', 'update_custom_field', 'create_custom_object'], + }, + required: { field: 'operation', value: ['create_custom_object'] }, + }, + { + id: 'pluralLabel', + title: 'Plural Label', + type: 'short-input', + placeholder: 'Plural display label (e.g., Projects)', + condition: { field: 'operation', value: ['create_custom_object'] }, + required: { field: 'operation', value: ['create_custom_object'] }, + }, + { + id: 'picklistValues', + title: 'Picklist Values', + type: 'short-input', + placeholder: 'Comma-separated values (e.g., Low, Medium, High)', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'length', + title: 'Length', + type: 'short-input', + placeholder: 'Max length for Text/LongTextArea/Html', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'precision', + title: 'Precision', + type: 'short-input', + placeholder: 'Total digits for Number/Currency/Percent', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'scale', + title: 'Scale', + type: 'short-input', + placeholder: 'Decimal places for numeric fields', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'visibleLines', + title: 'Visible Lines', + type: 'short-input', + placeholder: 'Lines for LongTextArea/Html/MultiselectPicklist', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'defaultValue', + title: 'Default Value', + type: 'short-input', + placeholder: 'Default value (true/false for Checkbox)', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'inlineHelpText', + title: 'Help Text', + type: 'short-input', + placeholder: 'Help text shown next to the field', + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'required', + title: 'Required', + type: 'dropdown', + options: [ + { label: 'Yes', id: 'true' }, + { label: 'No', id: 'false' }, + ], + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'unique', + title: 'Unique', + type: 'dropdown', + options: [ + { label: 'Yes', id: 'true' }, + { label: 'No', id: 'false' }, + ], + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'externalId', + title: 'External ID', + type: 'dropdown', + options: [ + { label: 'Yes', id: 'true' }, + { label: 'No', id: 'false' }, + ], + mode: 'advanced', + condition: { field: 'operation', value: ['create_custom_field', 'update_custom_field'] }, + }, + { + id: 'nameFieldLabel', + title: 'Name Field Label', + type: 'short-input', + placeholder: 'Label for the Name field (defaults to "