You need to sign in to do that
Don't have an account?
Custom button on custom object to convert to Person Account
i am attempting to create a custom button on a custom object (a recruiting-related object) that converts candidates under consideration to Person Accounts in the event that we do not hire them. i already have a custom button (JavaScript) set up on the Account object that allows conversion from Business Accounts to Person Accounts so I suspect what I want to do is possible, but I do not know how to code it. Can anyone here point me in the right direction? I unfortunately have the Name field in my custom object (Candidate Name) set up to capture both first and last name, so I may have to move all of that text into the Last Name field on the Person Account and then edit afterwards, but that is still better than manually starting a Person Account from scratch.
Ideally I would also want to migrate the street, city, state, and zip from the candidate record to the Person Account record. Can this all be accomplished with a custom button? Can you point me to any resources that would help me work out the correct code? Thanks in advance for any assistance you can offer!
To call a Apex class method from a button you need to define the method as "webservice".
You can call the method by using Ajax toolkit.
Below is the sample code.
Apex code:
global class class1{
WebService static Integer method1(String iTitle){
Your logic here
}
}
Custom button code:
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
var result = sforce.apex.execute("class1", "method1",{iTitle : noteTitle});
//Redirect to diff page or same page
window.location = 'https://n11.salesforce.com/'; ..any URL here