Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a scenario where I have to call a webservice whenever there is an update on the record of a standard page layout and handle the JSON output. Since it is on standardlayout I have used a trigger and an @future call but I am unable to return the JSON for the request. Is there any way to handle this or any suggestion on how to handle webservice call on standard layout will be appreciated.

share|improve this question

3 Answers 3

You cannot return a response from a trigger, which can be synchronously displayed to the user (other than using addError, which wouldn't fit your use case) . A trigger is meant mainly for business logic.

You could have a custom text field Result on the object, which you populate with the result of the ws callout after processing the json response.

If you must display the response to the user synchronously, you will need to override the standard button with a visualforce page or replace it with a custom button and use the Ajax toolkit to make the ws callout and display the response.

share|improve this answer

By handle the web service on the standard layout I assume you want to display the results from this webservice to the user as soon as they update the record.

Add an inline visualforce page to the page layout that runs an action method on page load that checks if the record was just updated by the running user and if so makes the webservice callout and displays the results on the page.

Depending on how often you need to query for the information from the webservice and how quickly it becomes out of date you can either just display the information on the vf page and not save it anywhere or save it on the sObject and only re-query for the information after a certain time-out period.

share|improve this answer

It is always better you make a custom button on the standard pagelayout and once an update is done for the record for specific fields indicate to the user by alert or pop up to press the custom button and on action of that button call the external service.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.