You need to sign in to do that
Don't have an account?
Error when updating layout: "Layout must contain an item for required layout field: Name"
Hi all,
My code creates a custom object via the API, and then it updates the default layout via the API also. This has been working fine, but today I receive the error "Layout must contain an item for required layout field: Name". What is causing this error message?
My package.xml file:
<?xml version="1.0"?>
<Package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>My_Custom_Object__c-My Custom Object Layout</members>
<name>Layout</name>
</types>
<version>17.0</version>
</Package>
My My_Custom_Object__c-My Custom Object Layout.layout file:
<?xml version="1.0"?>
<Layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://soap.sforce.com/2006/04/metadata">
<excludeButtons>Clone</excludeButtons>
<excludeButtons>Share</excludeButtons>
<excludeButtons>Submit</excludeButtons>
<excludeButtons>Edit</excludeButtons>
<excludeButtons>Delete</excludeButtons>
<layoutSections>
<editHeading>true</editHeading>
<label>Information</label>
<layoutColumns>
<layoutItems>
<behavior>Edit</behavior>
<field>Document_URL__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Created__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
<behavior>Edit</behavior>
<field>Lead__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Account__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Opportunity__c</field>
</layoutItems>
</layoutColumns>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<editHeading>true</editHeading>
<label>System Information</label>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<customLabel>true</customLabel>
<editHeading>true</editHeading>
<label>Custom Links</label>
<style>CustomLinks</style>
</layoutSections>
</Layout>
Can someone tell me why this has suddenly stopped working and what the "required layout field: Name" is?
Never mind, I have found the problem - I was interpreting the error message incorrectly. I assumed that this was a problem within the XML due to the changes to Spring 10, but in fact the error message means "There is a required field within your custom object called 'name', but you have not included it in the layout so nobody will ever be able to populate it".
I had changed the format of the 'name' field from autonumber to text, which makes it a required field, and therefore it *has* to be present on the layout.