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
sasayongsasayong 

Button in S-control to call another S-control

I have a form in SControl A and after submitting the form, a bunch of codes kick in and insert some entries into the database. How can i let the button or call SControl B after we have run the script correctly?
werewolfwerewolf
If you mean that Scontrol B is supposed to kick in when you save your object, why not do it in an Apex trigger instead?  That would be faster and easier.
sasayongsasayong
Thanks werewolf,

I managed to do it by  using this
--------------
if(result[0].getBoolean("success"))
{
alert("new report request created with id " + result[0].id + " - " + result[0].name);
var returl ="{!$SControl.Subject_Selection}&rptid=" + result[0].id;
alert(returl);
this.parent.location.href = returl;
}
--------------
the returned url is correct but missing the usual salesforce header(menus etc). I'm new to this so learning trigger would be another challenge. am reading the trigger help currently and is abit lost....

i managed to get to this though
--------------
trigger t on Report_Request__c (isAfter) {
}
--------------

does this mean i have to put what i suppositely wants SControl.Subject_Selection into this Trigger?
sasayongsasayong
someone already touched on this last year
http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&message.id=5317

but i still couldnt get this loaded properly with
window.parent.location.href = returl;


NaishadhNaishadh
this is because you tried to open new url in new window not inside parent window.

as per salesforce design one should execute his code inside body iframe try to open your new url inside the body iframe. hope it will solve your issue
sasayongsasayong
Exactly what i'm trying to do!! :(
sasayongsasayong
the issue is fixed by doing this instead

var returl = "{!URLFOR($Action.ObjectName.ButtonName)}";
SFGeekSFGeek
Hi,

URLfor tag is the best option, you can also try with

window.parent.parent.location.href = returl; instead of window.parent.location.href = returl;

Thanks & Regards,
SFGeek