1

This is the Question/Answer case, so here you wont find any details.

After Googling within few hours I found solution that you can find below.

1 Answer 1

2

simple_salesforce

from simple_salesforce import Salesforce


def custom_field_create:
    """
    Based on https://salesforce.stackexchange.com/a/212747/65221

    Examples of field types you can find in the column "Data Type" of the salesforce front end,
    on the page where you can create/edit/delete fields for your selected object.

    NOTE: case of "type" is important. For example the type "DateTime" 
          must be exactly "DateTime" and not like "datetime".
    """

    email = 'your_email'
    password = 'your_password'
    security_token = 'your_token'

    object_api_name = 'contact'  # replace with your object name
    field_api_name = 'Activity_Time'  # replace with your field name
    field_label = 'Activity Time'  # replace with your field label
    
    sf = Salesforce(username=email, password=password, security_token=security_token)
    url = 'tooling/sobjects/CustomField/'

    payload = {
        "Metadata":
            {"type": "Text", "inlineHelpText": "", "precision": None, "label": f"{field_label}", "length": 90, "required": False},
        "FullName": f"{object_api_name}.{field_api_name}__c"
    }

    result = sf.restful(url, method='POST', json=payload)
    print('result:', result)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.