salesforce_write_apex_trigger
Create or update Apex triggers in Salesforce to automate workflows by defining custom logic for specific Salesforce objects. Specify trigger name, object, and code body for efficient management.
Instructions
Create or update Apex triggers in Salesforce.
Examples:
- Create a new Apex trigger: { "operation": "create", "triggerName": "AccountTrigger", "objectName": "Account", "apiVersion": "58.0", "body": "trigger AccountTrigger on Account (before insert, before update) { /* implementation */ }" }
- Update an existing Apex trigger: { "operation": "update", "triggerName": "AccountTrigger", "body": "trigger AccountTrigger on Account (before insert, before update, after update) { /* updated implementation */ }" }
Notes:
- The operation must be either 'create' or 'update'
- For 'create' operations, triggerName, objectName, and body are required
- For 'update' operations, triggerName and body are required
- apiVersion is optional for 'create' (defaults to the latest version)
- The body must be valid Apex trigger code
- The triggerName in the body must match the triggerName parameter
- The objectName in the body must match the objectName parameter (for 'create')
- Status information is returned after successful operations
Input Schema
Name | Required | Description | Default |
---|---|---|---|
apiVersion | No | API version for the Apex trigger (e.g., '58.0') | |
body | Yes | Full body of the Apex trigger | |
objectName | No | Name of the Salesforce object the trigger is for (required for 'create') | |
operation | Yes | Whether to create a new trigger or update an existing one | |
triggerName | Yes | Name of the Apex trigger to create or update |