You need to sign in to do that
Don't have an account?
manav_mnv
Custom button to call Apex class....
Hi All
I have one urgent query, described below:
I have one custom object "Communication" with two record types 'Inbound' & 'Outbound'. I created one custom button on Inbound layout called 'Reply'.
Functianality on Reply button is:
functionality to Reply to a Communication is a custom 'Reply' button that has code to clone the original Communication record (thus preserving the original), change the Record Type to Outbound and open the new record in Edit view.
Just similar to mailing pattern to reply, the cloning record will contain the Subject, Recipient email, Message type, Reply content(these are the fields) to auto populate from Inbound record type record and in editable mode. and have below section in which the clone of original mail will come.
Please help me in solving this problem.
Regards
Manav
I have one urgent query, described below:
I have one custom object "Communication" with two record types 'Inbound' & 'Outbound'. I created one custom button on Inbound layout called 'Reply'.
Functianality on Reply button is:
functionality to Reply to a Communication is a custom 'Reply' button that has code to clone the original Communication record (thus preserving the original), change the Record Type to Outbound and open the new record in Edit view.
Just similar to mailing pattern to reply, the cloning record will contain the Subject, Recipient email, Message type, Reply content(these are the fields) to auto populate from Inbound record type record and in editable mode. and have below section in which the clone of original mail will come.
Please help me in solving this problem.
Regards
Manav
One way to call an Apex method via a custom button is to bounce the user through a custom Visualforce page that has the standardController set to the same object that custom button is defiend on. The extensions will include the Apex class that defines the method you want to call. Finally, the action will be the method you want to call.
There is a basic example How to call Apex Class methods from Customer Button or Link? (https://help.salesforce.com/apex/HTViewSolution?id=000006031&language=en_US)
Another good post on the concept is in Calling Apex Class from Custom Button, And Then Refreshing List View (http://salesforce.stackexchange.com/a/5246/102). This includes the considerations you should make if working on a managed package that may go through securtiy review.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var comobj = new sforce.SObject("Communication__c");
comobj.RecordTypeId = '012A000000xxxxx';
--any other data from the existin record using merge fields---
result = sforce.connection.create([comobj]);
if(result[0].getBoolean("success"))
{
parent.window.location = '/'+result[0].id + '\e?retURL={!Communication__c.id}';
}
else
{
alert(result[0].errors.message);
}
--yvk