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
chrisbellamychrisbellamy 

Creating a new field on an object with Apex code

Is there a way to create a new field on an object with Apex code?  I'm pretty sure it can be done with the Metadata API, but I wondered if there's a way directly from within Apex.

sebcossebcos

Hi Chris,

no, unfortunately this is not possible currently with Apex. Apex allows now for describe calls which are only for reading fields and objects' info but not for writing.