2

How do i set a custom field to be the name field of a particular custom object?

So far, I have created a custom object and while doing so I have create a namefield by using:

            <nameField>
                 <displayFormat>FIELD-{0000}</displayFormat>
                 <label>namefield__c</label>
                 <type>AutoNumber</type>
            </nameField>

Edit1:

<soapenv:Body>
<create xmlns="http://soap.sforce.com/2006/04/metadata">
<metadata xsi:type="ns2:CustomObject" xmlns:ns2="http://soap.sforce.com/2006/04/metadata">
<fullName>nokia__c</fullName>
<deploymentStatus>Deployed</deploymentStatus>
<description>created by the Metadata API</description>
<enableActivities>true</enableActivities>
<label>Dummy</label>
<nameField>
<displayFormat>NOKIA-{0000}</displayFormat>
<label>permission_c</label>
<type>AutoNumber</type>
</nameField>
<pluralLabel>Nokia</pluralLabel>
<sharingModel>ReadWrite</sharingModel>
<SearchLayouts>
<customTabListAdditionalFields>test__c</customTabListAdditionalFields>
</SearchLayouts>
</metadata>
</create>
</soapenv:Body>
4

You can't. The name field for any custom object will have the API name of Name, and for most standard objects, it will also be Name, with a few special exceptions, like Cases. You can only affect its data type (auto-number or text), its label, and its display format, when using auto-number.

| improve this answer | |
  • dropbox.com/s/s0caiczawrv94rd/… With reference to this screenshot, can i atleast create another column through which i push unique data into each of that column to make them unique as in a "Name" column in lead fields – Mohan Krishnan Jan 23 '17 at 18:09
  • @MohanKrishnan You can create a text field with the External Id attribute selected (and optionally Unique). This would let you specify your own API name, and you can use the upsert method against this field to insert/update records. – sfdcfox Jan 23 '17 at 18:12
  • ok. Will give it a try. – Mohan Krishnan Jan 23 '17 at 18:13
  • I studied external ids but couldnt get the desired output. To make things clear, I have atteached a screenshot which specifies my need. Pls take a look into it, and instruct me in the right direction. dropbox.com/s/1icg5nxhxq3c5wp/BeFunky%20Collage.jpg?dl=0 So I need to create a column link 'Company' which populates from a custom field inside the object – Mohan Krishnan Jan 23 '17 at 20:35
  • @MohanKrishnan You can edit the various layouts in your custom object under Search Layouts. – sfdcfox Jan 23 '17 at 20:43
0

First of all, the name field is a standard field (API name = name). Any custom field you'll create will have the "__c" extension. So there is no way you can really override the name field.

Having said that, why don't you simply edit the standard name field and change it to be an auto-number?

Object creation

Name field auto-number

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.