i have created one button on record top beside the clone button, when clicked, execute code that would make a new version record with the same name and append today's date on the end of the name to distinguish it from the original.i created apex class and custom list button but the i clicked on button so java script does'not working on this.so below error occour during click on the button.
How should i do this ?
Apex class:-
global class CloneVersionwithText
{
webservice static void cloneMSAVersion(Id msaId) // you can pass parameters
{
List<MSA_Text_Block__c> MText = new List<MSA_Text_Block__c>();
Master_Service_Agreement_Version__c msa = [SELECT ID, Name FROM Master_Service_Agreement_Version__c WHERE Id = : msaId];
Master_Service_Agreement_Version__c msaCopy = msa.clone(false,true);
msaCopy.Name = msa.Name +'-'+system.today();
insert msaCopy;
//cloning Related MSA Text Records
for(MSA_Text_Block__c c : [SELECT Id, Name, Service__c, Order_within_Service__c,Master_Service_Agreement_Version__r.ID FROM MSA_Text_Block__c WHERE Master_Service_Agreement_Version__r.ID = : msa.Id]){
MSA_Text_Block__c textCopy = c.clone(false,true);
textCopy.Master_Service_Agreement_Version__r.ID = msaCopy.Id;
MText.add(textCopy);
}
insert MText;
}
}
create a java script button to call the apex class
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
sforce.apex.execute("CloneVersionwithText","cloneMSAVersion",{msaId{!Master_Service_Agreement_Version__c.Id}}"});