You need to sign in to do that
Don't have an account?
The new Learner
After cloning the record , record id need to populate in another field---urgnt
Hi Experts,
I have small requirement , i need to create custom clone button on opportunity for prospecting record type opportunity record, so when ever i click on that particular button , prospecting record type opportunity need to clone and that respected record id needs to populate in a field called Prospecting_opportunity__c(field will be there in the same opportunity object
Thanks in advance
I have small requirement , i need to create custom clone button on opportunity for prospecting record type opportunity record, so when ever i click on that particular button , prospecting record type opportunity need to clone and that respected record id needs to populate in a field called Prospecting_opportunity__c(field will be there in the same opportunity object
Thanks in advance
I have requirment that is there is an Record type called Prospecting and i have custom clone button on the Prospecting record type record which is there in the Opportunity.
When ever i click on that Prospecting record type record a new record has to create and it need to populate the parent record(original record which i cloned) that id needs to populate in field called 'Prospecting_Opportunity__c'. i wrote code but its throwing validations rules of another record type can you guys help me pleaes.
Apex class code:
global class customClone
{
webservice static void cloneAccount(Id acctId) // you can pass parameters
{
Opportunity acc = [SELECT ID, Name,recordtypeid FROM Opportunity WHERE Id = : acctId];
//Id AccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('200+').getRecordTypeId();
Opportunity newacc=acc.clone(false);
newacc.Prospecting_Opportunity__c=acc.id;
newacc.Name = acc.Name +'-'+'Cloned';
insert newacc;
}
}
Button code:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var opptyId='{!Opportunity.Id}';
sforce.apex.execute("customClone","cloneAccount",{acctId: opptyId});
Thanks in advance
The Following code will hopefully solve your problem. please let us know if your still having any issues.
If your problem is solved, please mark the question as solved.
Thanks
Arshad
I am receving button related errors.
I have created a custom button which looks like below image and its working fine for me.
Please make sure, if the org has namespace.
sforce.apex.execute('namespace.customClone'....
Let me know if you still have further issues.
Thanks
Arshad
arshadulla.shariff@gmail.com
Did you figure out the issue, let us know the solution.
So that it can help the community .
Thanks.
public class customClone
{
public static void cloneOpportunity(Id oldopptId) // you can pass parameters
{
Opportunity oldopp= [SELECT ID, Name,recordtypeid FROM Opportunity WHERE Id = : oldopptId];
//Opportunity newopp= oldopp.clone(false,true);
Opportunity newopp=new Opportunity();
newopp.name=oldopp.name+'-'+'Cloned';
//newopp.recordtypeid = oldopp.recordtypeid;
//newopp.Prospecting_Opportunity__c=oldopp.id;
//newopp.Name = oldopp.Name +'-'+'Cloned';
insert newopp;
}
}
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var newAccid = sforce.apex.execute("customClone","cloneOpportunity",{oldopptId:"{!Opportunity.Id}"});
window.location.href="/"+newAccid;
Try replacing your code with below and Test .
Hope this will solve your problem.
Thanks