create_record
Generate Salesforce records by specifying the object name and data. Integrate with Salesforce Connector to manage CRM data effectively via API operations.
Instructions
Creates a new record
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | The data for the new record | |
| object_name | Yes | The name of the Salesforce object (e.g., 'Account', 'Contact') |
Implementation Reference
- src/salesforce/server.py:369-383 (handler)The handler logic for the 'create_record' tool. It extracts object_name and data from arguments, validates them, connects to Salesforce if needed, creates the record using simple-salesforce's create method, and returns the result as JSON.elif name == "create_record": object_name = arguments.get("object_name") data = arguments.get("data") if not object_name or not data: raise ValueError("Missing 'object_name' or 'data' argument") if not sf_client.sf: raise ValueError("Salesforce connection not established.") sf_object = getattr(sf_client.sf, object_name) results = sf_object.create(data) return [ types.TextContent( type="text", text=f"Create {object_name} Record Result (JSON):\n{json.dumps(results, indent=2)}", ) ]
- src/salesforce/server.py:167-186 (registration)Registration of the 'create_record' tool in the list_tools handler, including its description and input schema for object_name and data.types.Tool( name="create_record", description="Creates a new record", inputSchema={ "type": "object", "properties": { "object_name": { "type": "string", "description": "The name of the Salesforce object (e.g., 'Account', 'Contact')", }, "data": { "type": "object", "description": "The data for the new record", "properties": {}, "additionalProperties": True, }, }, "required": ["object_name", "data"], }, ),
- src/salesforce/server.py:167-186 (schema)Input schema definition for the 'create_record' tool, specifying required object_name (string) and data (object).types.Tool( name="create_record", description="Creates a new record", inputSchema={ "type": "object", "properties": { "object_name": { "type": "string", "description": "The name of the Salesforce object (e.g., 'Account', 'Contact')", }, "data": { "type": "object", "description": "The data for the new record", "properties": {}, "additionalProperties": True, }, }, "required": ["object_name", "data"], }, ),