+ Start a Discussion

How to call a S-Control From a Trigger?

Hi all,
Please tell me how to call a S-Control from a Trigger? My case, when a contact is created, I had to call S-Control to get data by using Webservice API from external application.
Ron HessRon Hess
Sorry, this is not directly possible.

The trigger runs on our servers, and as you know scontrols run in a client browser which may or may not be running when the trigger is running.  the two are not connected.

you can call out to your service to clean up data, from Apex Code , but not from a trigger.

normally you would create a button , from the button call scontrol or apex to perform the callout which can then clean up your data.

What I suggest is to create a checkbox field which value would be reset (unmarked) everytime the trigger has been activated, So you could know when the execution of the scontrol is required and throught the scontrol set the chekbox field to the normal state after reciving the webservice response (this is only recommended if the event is not often).

Other way could be to send an email to the user in order to notify the required action. Perhaps there are other chances using ApexCode to consume the external webservice invoking a Salesforce webservice method from the trigger.

The problem it how activate S-Control from Trigger. I want when user add/update an Account, Trigger will add/update data into my custom object (Address), the data to add/update into my custom object is get from external application (by webservice API).
I spent a lot of time to do it or anyway to do it, I can't find out solution to resolve the above issue. can you share me how to resolve it?
Many thanks
Did you find a solution for this, even I am struggling to call a Sales Force S-control or Java Script from Apex Class/Trigger. They say Apex class is in Server and object/Page at Client side and we can do other way around

Hi lalit,


well, as Ron Hess said, it is not possible to do this directly. I suggest you to use the trigger in order to mark the record and later, with a scripting toolkit program (which could have the scontrol logic because it is mostly javascript or just to call out an apex webservice class) look for the marked records and do what you need in a bulk process.


Other possibility is to write the scontrol logic into an apexwebservice and call it from the trigger.


I hope this helps,