+ Start a Discussion
Apex Code DevelopmentApex Code Development 

How to send information contained in a record to java web service on a button click

Hi Folks!


I have created a custom object "Sales Order" and a tab for this object.


I clicked on the tab and created a new record.So in the view page of this record we will be having a "Submit" button along with "Edit" and "Cancel" buttons.


When I click on this "Submit" button, the information(ie., the fields) in that particular record should be appended to the web-service URL.


Please let me know how to proceed to achieve this since I am new to web-services in Salesforce.


Please note that the entire page is the standard page.


Thanks & Regards,

Jagadeesh K.


Here is one way that you can execute a piece of Apex code from a button added to a standard Page Layout - http://developer.force.com/cookbook/recipe/creating-a-button-with-apex. There is more than one way to skin this cat though. You could also develop a custom VF page and associate that with the custom button. The VF page would invoke a controller method in the 'action' attribute of the page. That would result in your Apex code being exeuted on page load. This design would result in a new pop-up page, everytime that the user clicks on the 'Submit' button, but that may not be a bad thing. You could for e.g. show success/error messages on that pop-up page.


That takes care of invoking a piece of Apex code from a custom button. As to how you'd have that piece of Apex code communicate with your external web service, check out this section of the Apex Dev guide  - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts.htm. Note that your description of the external service was a little confusing. I wasn't sure if this was a SOAP/WSDL service (the traditional definition of a 'Web Service') that needed to be invoked, or more of a RESTful service with data being passed as GET/POST params. Either way, the Apex dev guide should help.

Best of luck!