You need to sign in to do that
Don't have an account?
Nirmal9114
clone account : HELP
i requirement is to clone account with related list.
i am not able to clone related list in this trigger. CAN YOU PLEASE HELP
javascript url :
window.location.href = '/{!Account.Id}/e?clone=1&00N17000000oxkw_ileinner={!Account.Id}';
trigger:
trigger AccountCloning on Account (after insert) {
static Id cloneAccount(Id acctId)
{
List<Contact> cont = new List<Contact>();
List<Opportunity> opp = new List<Opportunity>();
Account acc = [SELECT ID, Name, Organization_Legal_Name__c, FGM_Base__EIN__c, Phone, ShippingAddress, Website, BillingAddress FROM Account WHERE Id = : acctId];
Account accCopy = acc.clone(false,true);
accCopy.Name = acc.Name +'-'+system.today();
insert accCopy;
//cloning Related contact Records
for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
Contact conCopy = c.clone(false,true);
conCopy.AccountId = accCopy.Id;
cont.add(conCopy);
}
insert cont;
return accCopy.Id;
}
}
i am not able to clone related list in this trigger. CAN YOU PLEASE HELP
javascript url :
window.location.href = '/{!Account.Id}/e?clone=1&00N17000000oxkw_ileinner={!Account.Id}';
trigger:
trigger AccountCloning on Account (after insert) {
static Id cloneAccount(Id acctId)
{
List<Contact> cont = new List<Contact>();
List<Opportunity> opp = new List<Opportunity>();
Account acc = [SELECT ID, Name, Organization_Legal_Name__c, FGM_Base__EIN__c, Phone, ShippingAddress, Website, BillingAddress FROM Account WHERE Id = : acctId];
Account accCopy = acc.clone(false,true);
accCopy.Name = acc.Name +'-'+system.today();
insert accCopy;
//cloning Related contact Records
for(Contact c : [SELECT Id, LastName, AccountId FROM Contact WHERE AccountId = : acc.Id]){
Contact conCopy = c.clone(false,true);
conCopy.AccountId = accCopy.Id;
cont.add(conCopy);
}
insert cont;
return accCopy.Id;
}
}
Refer the below link you get some idea,
https://developer.salesforce.com/forums/?id=906F0000000BTJ8IAO
http://www.infallibletechie.com/2013/06/how-clone-record-with-related-records.html
Thanks,
Vijay
these links are not helping me. i am working on tigger through which i can clone.
please help me with the code i was also jus trying to figure out.
thanks