function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JvalleeJvallee 

Custom Field: Adding to PageLayout with API and Making Field Available to API.

I have been able to create a custom field through the Metadata API, which is great. But now to be able to use it, I need to be able to add it to all appropriate Page Layouts and Make it available in the WSDL.

So first question, how can I add a custom field to a Page Layout with the API?  I tried creating a Layout object (inherits from Metadata) and using the Metadata API call create to create the new object which causes a "Field Integrity Exception" with a message of  "Parent entity failed to deploy" so I think that I'm close, but the message doesn't really mean much to me.

Second, once I create a new field, I want to be able to query for it.  Is there a way to dynamically update the WDSL to reflect the new field?

JvalleeJvallee
the "Parent Entity not Deployed" error was caused because I used the wrong syntax to refer to the Layout.  When working with sObjects or even Custom objects the fullname of an object would take the Object.Property syntax.  Lead.Email for example would be used to access the Email field of the Lead object.  It seem that for Metadata object (or at least Layouts) the "." is replaced by the "-" so you would use "Lead-LayoutName" to access the Layout.
visualforce_devvisualforce_dev

Hi Jvallee,

 

Even I am facing the same problem. I am able to create fields from api but only fields marked required is visible in the standard page layout created along with custom object.

 

if you have sample code pls share,

 

Thanks in advance

 

JvalleeJvallee
You need to add the newly added field tothe page layout.  Currently the only way that I know to do this, is through the Salesforce Setup console on the web site.  I am working on updating Layout programmatically, but it is a bit too difficult for the time I have.  You can layouts are Metadata, so you will need to use the Metadata API to get to the data.  You will use the retrieve function to get the layout.  Which will be returned as a zip file as a byte stream.  This is where I get stuck .Net does not seem to include a library for reading the contents of a zip archive that contains more than one file or directory, which is the case in Salesforce.
SFDeveloperoneSFDeveloperone

Hi

RamyaKrishnaRamyaKrishna

Hi,

 

Could you please tell me how can i access report data (meta data like names, etc) from Meta data Api?