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
vasu takasivasu takasi 

how to create a custom field from apex ..?

Hi,

I want to create a custom field for OpportunityLineItem from apex.

How is it Possible?

Please can any one guide me.

 

Jeff MayJeff May

You can't create a new custom field from Apex.  That would require the Metadata API.  You can populate custom fields in Apex.

Tejpal KumawatTejpal Kumawat

Hi vasu,

 

Taking an example of add custom field "Address(Address__c)" of LongTextArea of 32768 character for OpportunityLineItem.

 

You can easily create Custom Field if you are using  Force.com IDE or Eclipse by Putting below xml between <CustomObject> </CustomObject> tags of OpportunityLineItem.

 

<fields>
<fullName>Address__c</fullName>
<externalId>false</externalId>
<label>Address</label>
<length>32768</length>
<type>LongTextArea</type>
<visibleLines>3</visibleLines>
</fields>

 

 

Thanks & Regards

Tejpal

sandeep@Salesforcesandeep@Salesforce

We can not create custom objects & custom fields from Apex. even we have some other option to create to create these meta Data from Eclipse using xml. 

 

Please give me KUDOS and mark it as solution if it was helpful

rajesh k 10rajesh k 10
Hi vasu takasi,
                          using  metadata api you create field any object in salesforce.find belo URL
http://andyinthecloud.com/category/metadata-api/