You need to sign in to do that
Don't have an account?
AshDon
Records from Custom object to Standard object
Hi,
I have an apex class in there I need to transfer a record from custom object to standard object if the orderID (field in custom object) is matching with the orderID i have in the apex class.
Can someone help.
Thanks.
I have an apex class in there I need to transfer a record from custom object to standard object if the orderID (field in custom object) is matching with the orderID i have in the apex class.
Can someone help.
Thanks.
We cannot change the record from one object to another object. Instead of that we can delete the old record and create a new record for the required object.
If this solution helps, Please mark it as best answer.
Thanks,
Thank you fo your reply.
Is there any possible way we can store the records that are in custom object to standard object ? I dont want to delete the record in custom object I just want the same record in standard object.
Hi AshDon,
Please following the steps to move records from custom object to standard object
Please Mark if you helps :)
(1) Export all records from your custom object
(2) Import file by the dataloader.io
(3) please do mapping the fields to store record
Thanks
1. Is there any relationship between custom and standard object?
2.Standard object have same fields which are available in custom object?
Hi,
I want to do it inside an apex class.
@Ankaiah
Hi,
1. No relation between the objects.
2.Yes both objects have the same fields.
Standard object will have predefiend records with orderIds?. if yes then we can able to transfer the data from custom object to standard object.
try with below code.
If this helps, please mark it as best answer.
Thanks,
Ankaiah
Please Try Below Code and Select Best If it helps.
Map<String,Account> MapAcc = New Map<String,Account>();
for(Account standardobj : [select id,Name,orderID FROM Account]){
if(!MapAcc.containsKey(standardobj.orderID)){
MapAcc.put(standardobj.orderID,standardobj);
}
}
List<Account> AddAccList = new List<Account>();
for(CustomObject__c customobj : [select id,Name,orderID FROM CustomObject__c]){
if(MapAcc.containsKey(customobj.orderID)){
MapAcc.get(customobj.orderID).Name = customobj.Name;
AddAccList.add(MapAcc.get(customobj.orderID));
}
}
if(AddAccList.size() > 0){
update AddAccList;
}
Thanks