function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
onstate.nkeeneyonstate.nkeeney 

Launching an S-Control from a Trigger?

Hey all,

I have an Apex Code trigger which I would like to "launch" an S-Control when it executes. The S-Control really just contains a bit of JavaScript code, so my ultimate goal is to execute a snippet of JavaScript code when the Trigger runs. Is there any way to do this?

Thanks!
-Nathan
Ron HessRon Hess
no, no way to run UI from Apex code, only put up an error message if you are blocking a save from happening.  
onstate.nkeeneyonstate.nkeeney
Thanks for the quick response.

Maybe you could give me an idea of a workaround for what we're trying to do:

We wish to send an API command from our (external) servers to set a variable on an object, say: a UserID on our custom object. We then want to cause a "Screen Pop" - a popup window (or tab) to display which shows the detail view of that user (Account, Contact, etc) -- automatically.

The first and second parts are working - we can use the API to set the UserID we wish to display, and then we have a WebLink which causes that user's detail page to display.... we just need something to automatically "click" that link -- or otherwise cause the JavaScript on it to execute... any ideas? Triggers? Workflows? S-Controls?

Thanks!
-Nathan
Ron HessRon Hess
never tried it, but..

you could use the api to create an event with a reminder, only the due time is now.
that should pop the reminder, which has a link to the desired page.

or, build your own polling scontrol that is placed on the left side bar as an inline scontrol and checks for the new user id matching their own, and perform the popup and navigate functions.
onstate.nkeeneyonstate.nkeeney
I will try those suggestions. Thank you very much. :)

-Nathan
onstate.nkeeneyonstate.nkeeney
I tried the second option first, and it looks like it's going to work!

One question, though, is how do I put a custom S-Control in the sidebar? I tried using the Customize section of the Setup screen, but it appears to only allow adding s-controls to the home page layout, not to the sidebars of all pages.

Anyway, thank you very much for your excellent suggestions. :)
-Nathan
sfdcfoxsfdcfox
I did something just like that. Click «right here» to the post I wrote about a Sidebar S-Control.

~ sfdcfox ~
onstate.nkeeneyonstate.nkeeney
sfdcfox,

I looked at the fieldLevelHelp app you posted, but I don't see any inline S-Controls in the side bar, except the Message Window... is that what you meant? I couldn't see anything in the Setup section that shows me how to inline an S-Control into that sidebar... Could you start me out in the right direction? Thanks!

-Nathan
sfdcfoxsfdcfox
My S-Control is "hidden" using a style sheet command. I commented on this technique in the original post. The "hint" that there is an embedded S-Control is a message on the sidebar that reads "Field Level Help Enabled".

Basically, you write an S-Control, then create a custom home page component of type "HTML", choose the "show HTML" checkbox, and type in the following code:

<iframe src="/servlet/servlet.Integration?lid=XXXXXXXXXXX" style="display: none"></iframe>

After you save this change and add it to the home page sidebar, it will execute on any page that includes the sidebar. The "lid" parameter is the ID of the S-Control to execute.

~ sfdcfox ~
onstate.nkeeneyonstate.nkeeney
Very cool solution! Thanks for sharing the idea with me... works like a charm, and with the "Add custom controls to all tabs" option, my SControl becomes more or less persistent!

Thanks again,
-Nathan