+ Start a Discussion
Shaka MooreShaka Moore 

Add A Custom Button To The Case Page That Triggers An Outbound Message


I would like to add a custom button to the case page that, when clicked, triggers an outbound message of the case's details.

How can I do this? Or is their a better solution to this problem?
Daniel BallingerDaniel Ballinger
An outbound message is typically started by a field update on the affected record. You will need to start the process based on a Workflow rule evaluation criteria (https://help.salesforce.com/htviewhelpdoc?id=creating_workflow_rules_configure_settings.htm&siteLang=en_US). So, for example, you could have a field that you update to indicate that the outbound message should be sent via the workflow rule. You may want to promote the idea Outbound Message Element for Visual Workflow (https://success.salesforce.com/ideaView?id=08730000000l4ZKAAY).

The alternative is to use straight Apex to make a callout and completely bypass the outbound message functionality. This could call a range of SOAP or REST APIs.
Shaka MooreShaka Moore
Thanks for your help. Can you point me to an example in which I create a web service method using the APEX class, and call that method externally through a REST API. i.e https://www.mywebsite.com/api/
Daniel BallingerDaniel Ballinger
You can connect Apex code to a custom button using the steps in Call an Apex Class Method Using a Button (https://developer.salesforce.com/docs/atlas.en-us.workbook.meta/workbook/button_intro.htm).
From there you can interact with external SOAP or REST web services. SOAP can use Wsdl2Apex. For REST you can use HttpRequest and HttpResponse.

You can host your own REST service in Apex with the example from Apex REST Basic Code Sample (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_code_sample_basic.htm). This includes curl examples for calling the service.