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
SanalSanal 

How to execute and S-Control from another S-Control?

In an S-Control, I'm retrieving the HTMLWrapper (to a string) using sforceClient.Query("Select HtmlWrapper From SControl where Id='"+str+"'");. i want to run the retrieved S-Control script. But, when i used document.write() to run the script, it throws the following error!

A Runtime Error has occurred.
Do you wish to Debug?

Line: 29
Error: 'sforceClient' is undefined.

Am i using bad logic to run the script?

Putting the whole thing in a simple way, How can I execute an S-Control from another S-Control? Please help!

Thanks in advance.
Sanal
DevAngelDevAngel
Hmm... never thought of doing it that way. You don't want to do document.write in you main html area, but you could try using an iframe for that, ie. iframe.document.write.

You can also, which may suit you better, navigate to the other scontrol using /servlet/servlet.Integration?lid=01ND00000000B6s&enc=UTF-8 where lid is the id of the scontrol.

Using that url you might want to do document.location.href = or some other navigational technique.
Mike ShawalukMike Shawaluk
I'm doing this in some of my s-controls, where I "chain" from one s-control to another. Here's how I'm doing it:

var baseURL = "https://na1.salesforce.com/";
...
saveResult = sforceClient.Update(someArray);
...
var scQuery = sforceClient.Query("Select Id from Scontrol Where Name ='name of scontrol'");
window.location.href = baseURL + "servlet/servlet.Integration?lid=" + scQuery.records[0].get("Id") + "&eid=" + saveResult[0].id + "&enc=UTF-8";

In the above example, I update a record in a custom object, and then invoke the new s-control, passing the updated record's ID. Seems to work well for me.

- Mike
SanalSanal

Hi,

Thanks Dave and Mike. As I got the URL to be navigated for displaying an S-Control, the issue got resolved by using simple navigation techniques as specified in the previous messages. 

[Sorry for the delay due to a major health problem]

Sanal.