I would like to set the description for all object fields that are layoutable but not present in any layout to: "Not used". I found out how to find fields that are layoutable, but I can't find out how to set the description of a Field using simple_salesforce.

I assume it must be done using the Metadata API, but I couldn't find an example anywhere. I couldn't figure it out myself either. I'd like to do it for all types of fields (both from standard and custom objects).

How can I set the description of a field using simple_salesforce?

Example pseudocode:

sf.objects["Account"].fields["AccountNumber"].set_description("Not used")

1 Answer 1


You can use mdapi as indicated here. I am not an expert in python, ignore any syntax issues.

    mdapi = sf.mdapi
    custom_object = mdapi.CustomObject.read("Account")
    custom_field = mdapi.CustomField(
        fullName = "AccountNumber",
        description = "Not used"
    custom_object.fields = [custom_field]


I haven't dry-tested this code, shared here hoping this might help you. Here you can find more details about the list of attributes that we update through metadata API calls in the salesforce.

  • 1
    I'll test this later today, thanks for the advice! If it works, i'll accept it.
    – ThaNoob
    Commented Apr 15, 2022 at 14:40
  • 1
    Works perfectly. A bit confusing that you have to say that Account is a custom object, but it works.
    – ThaNoob
    Commented Apr 15, 2022 at 15:22
  • 1
    For those also needing to add help text, just use mdapi.CustomField(fullName = "AccountNumber", description = "Not used", inlineHelpText="Not used")
    – ThaNoob
    Commented Apr 15, 2022 at 15:29
  • +1 for validating this @ThaNoob Commented Apr 17, 2022 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .