---
schema_version: "1"
id: e98e4277d1484612a7a7c997c6a80151c8410900b5915ce88c86981e3ffa1999
title: schema generate field
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/schema/cli_reference_schema_generate_field.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_schema_generate_field.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b46933cde847e769c2e10a1185ac65d01223699afad148dd340c022dbbe87af3
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# schema generate field

Generate metadata source files for a new custom field on a specified object.

## Description for schema generate field

This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the field's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other field properties, such as its API name.

You can generate a custom field on either a standard object, such as Account, or a custom object. In both cases, the source files for the object must already exist in your local project before you run this command. If you create a relationship field, the source files for the parent object must also exist in your local directory. Use the command "sf metadata retrieve -m CustomObject:&lt;object&gt;" to retrieve source files for both standard and custom objects from your org. To create a custom object, run the "sf generate metadata sobject" command or use the Object Manager UI in your Salesforce org.

## Aliases for schema generate field

`generate:metadata:field`

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;label</code> | <code>&#8209;l</code> | **Type:** Value<br>**Required**<br><br>The field's label. |
| <code>&#8209;&#8209;object</code> | <code>&#8209;o</code> | **Type:** Value<br><br>The directory that contains the object's source files.<br><br>The object source files in your local project are grouped in a directoy with the same name as the object. Custom object names always end in "__c". An example of the object directory for the Account standard object is "force-app/main/default/objects/Account" An example custom object directory is "force-app/main/default/objects/MyObject__c"<br><br>If you don't specify this flag, the command prompts you to choose from your local objects. |

## Examples for schema generate field

Create a field with the specified label; the command prompts you for the object:

```shell
sf schema generate field --label "My Field"
```

Specify the local path to the object's folder:

```shell
sf schema generate field --label "My Field" --object force-app/main/default/objects/MyObject__c
```
<!-- prettier-ignore-end -->
