Quantcast
Channel: Programming – Rey Rahadian
Viewing all articles
Browse latest Browse all 31

Debugging Salesforce Callout

$
0
0

Inside of the Salesforce Apex class we can have a bit of code that execute an http request call to an external site, for example if we have a need to send information from Salesforce to an external site. Normally i would use Salesforce outbound message as it has more feature such as resend the message if the first request failed, able to send bulk messages and so on.

However Salesforce Outbound Message as part of the workflow can only be triggered on the create and update event of an entity. Therefore if we want to send information about the entity that is being manipulated on the delete event it’s not possible to do that.

The workaround is to use Apex Trigger that uses HttpRequest class to POST data to an external site, it could a be webservice and aspx page you get the idea. The downside is that there isn’t an easy way to see the debug log to see if the callout succeed or not when we execute the method because when we write a method that contain callout, that method has to be mark with @future(callout=true) and thus making it run asynchronously. Because of this all the log that we set inside the callout method will not showup on the developer console log viewer. Or is it..

Using the developer console, we can execute an Apex Code to trigger a callout, and then we can see the log just fine.

image

image

Make sure you tick the Open Log so that it opens the log viewer after executing the code

image

And then there’s the exception that i want to see.

a simple example of creating apex trigger and executing callout
http://cheenath.com/?tutorial/sfdc/sample1/index.html

checkout this link if you’re interested with viewing the http raw data when executing the callout
http://sfdc.arrowpointe.com/2010/02/16/endpoint-for-debugging-http-callouts/



Viewing all articles
Browse latest Browse all 31

Trending Articles