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
abdnabdn 

Customizing Object's layout using metadata API (PHP Toolkit)

HI...

I am developing a web application integrated with salesforce. I used REST API and SOAP API (PHP Toolkit) for integration. The application creates a custom field on Contact.  This field must be shown on the Contact detail page hence must be added to Contact's layout. I am able to create the field by using metadata api by PHP coding but the problem is now how to add the field to the Contact's Layout. I read php toolkit documentations but did not found any help. Any one there got any Idea how to do this?

Best Answer chosen by Admin (Salesforce Developers) 
Pat PattersonPat Patterson

Layout uses file-based deploy/retrieve calls, which involve zipping and unzipping package directories. The PHP toolkit only supports CRUD operations, so it's not possible to do this from PHP without implementing a lot of code yourself.

 

You would need to add the deploy/retrieve calls, retrieve() the existing Layout as a zipped package directory, unzip it, parse the Layout XML, add your field, write the new Layout XML into the package directory, zip it up, and send it in a deploy() call as base64-encoded data.

 

Doable, but a LOT of work! You might do better with the Java WSC - there is sample code for deploy and retrieve.