Here’s a simple snippet for creating a new custom object in Salesforce in Python.
from simple_salesforce import Salesforce
sf = Salesforce(
username='',
password='',
security_token='',
domain='login'
)
try:
mdapi = sf.mdapi
custom_object = mdapi.CustomObject(
fullName="Object11__c",
label="Custom Object 1",
pluralLabel="Custom Objects",
nameField=mdapi.CustomField(
label="Name__c",
type=mdapi.FieldType("Text")
),
deploymentStatus=mdapi.DeploymentStatus("Deployed"),
sharingModel=mdapi.SharingModel("Read")
)
mdapi.CustomObject.create(custom_object)
except Exception as e:
print(e)
Written by
Abdur-Rahmaan Janhangeer
Chef
Python author of 7+ years having worked for Python companies around the world
Suggested Posts
Upload your package to Pypi
To upload your project to Pypi, this assumes you have your setup.py ready cd into your package direc...
Python EFL: Building Custom Elementary Widgets (2026)
Want to create unique UI components tailored to your app’s needs? This Python EFL tutorial teaches y...
Python EFL: Scalable GUIs with Generic List (Genlist) (2026)
Handling thousands of UI elements without slowing down your app? This Python EFL tutorial introduces...