You need to sign in to do that
Don't have an account?
Create custom fields in apex code
Hi all,
Is there any possibility to create (dynamically create) custom fields in apex code?In that case we have to access schema. isn't it? How can i do this?
Thanks in Advance
You can theoretically create new fields using the CRUD-based Metadata API calls, but as this API is asynchronous, you may not be able to detect if the fields were successfully created in the same run as the attempt to create the fields. If you are using Visualforce to present the UI for this Apex Code, you could have the page call a function in the Apex Code that could check for the asynchronous results until a given timeout period. If you try this any other way (for example, from a trigger), then you would not be able to detect the success of your attempts at all. There is no technological reason why you could not create fields on the fly using Visualforce, but using pure Apex Code without Visualforce would be difficult, if not impossible, to use accurately.
HI,
You can create new fields dynamically through apex code.
Sridhar Bonagiri
Hi, are there any examples of this?