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
sree sfdcsree sfdc 

standard object convert to custom object using buttons ?

hi floks,

i  have requirmenet ,

how to create custom convert button .to convert standarad object to custom object  .
 pls help me how to do this  ..


thanks 
Best Answer chosen by sree sfdc
Deepak Kumar ShyoranDeepak Kumar Shyoran
You need to modify the above method and then paste it in your Apex class.

Then after on you VF page associated with that class you have to call this method by using following syntex
<apex:form>
<apex:commandButton action="{!convertToCustomObject" value="Convert To Custom Object" />
</apex:form>
Please mark my answer as a solution to your question if it solves your problem.


All Answers

Deepak Kumar ShyoranDeepak Kumar Shyoran
It depends on what fields are required on your custom object you want to convert in and what fields value you want from your standard object into you custom object.

For example.

If you want to convert a Account object records to your custom Account then you need to do some thing like below example.

public void convertToCustomObject() {
 Account acc = [Select Name,AccountNumber from Account where id = '001XXXXXXXX' ] ;
 MyCustomAccount__c customAccount= new MyCustomAccount__c (Name=acc.Name,AccountNumber__c = acc.AccountNumber ) ;
 insert customAccount ;


}


Please mark my answer as a solution to your question if it solves your problem.
sree sfdcsree sfdc
H deepak,

it's possible to buttons ?if yes how to do please explain .
Deepak Kumar ShyoranDeepak Kumar Shyoran
You need to modify the above method and then paste it in your Apex class.

Then after on you VF page associated with that class you have to call this method by using following syntex
<apex:form>
<apex:commandButton action="{!convertToCustomObject" value="Convert To Custom Object" />
</apex:form>
Please mark my answer as a solution to your question if it solves your problem.


This was selected as the best answer