I'm a bit of a novice when it comes to Salesforce development. Basically, I'm branching out from triggers/scheduleable classes. What I'm trying to do is create a custom button that runs a class to "clone" some fields from an account into a new account of a different type. I followed the webservice template pretty closely on the developer guide but I'm getting nowhere. When I click my custom button I get
"A problem with the OnClick JavaScript for this button or link was encountered:Cannot read property 'push' of undefined"
Hopefully someone can see where I'm going wrong and point me in the right direction.
Class:
global with sharing class KA_Clone {
webservice static Id Mk_Ka(Account a) {
account a2 = New account(Parent = a.Parent, name = a.Parent.Name +'- Key Account',
Parent_Account_External_ID__c = a.Parent_Account_External_ID__c,
BillingStreet = a.BillingStreet,
BillingState = a.BillingState,
BillingPostalCode = a.BillingPostalCode,
RecordTypeId = '012F0000001MHUN');
insert a2;
return a2.id;
}
}
Button Code:
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/31.0/apex.js")}
var account = sforce.SObject("Account");
var result = sforce.apex.execute("KA_Clone","Mk_Ka",{a:account});