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
MSheridanMSheridan 

S-Control to override New Button and populate Fields on custom Object

Hi!
I'm new to writing S-Controls so I really don't know where to begin. I need to override the new button on a custom object so two fields (Case Owner & Phone) pre-populate when the user hits "New". Basically, I want to keep the standard New Action but added in my own code. I don't want to have to user click more than once. This is all I could come with up and it does not work. Any help would be greatly appreciated!! Code:
<script language="JavaScript"> 
window.parent.location.href="{!URLFOR($Action.Banking_Svs_Research_Req__c.New, null,null,true)}"; 
function redirect() { 
parent.frames.location.replace("/{! Banking_Svs_Research_Req__c.Id }/e—retURL=%2F{!Banking_Svs_Research_Req__c.Id}&00NT0000000iTK0={!Case.OwnerFullName}&00NT0000000iTuS={!Case.SuppliedPhone}&save=x") 
} 
redirect(); 
</script>

 
CaptainObviousCaptainObvious

Silly question, but did you make the toolkit available in your s-control?

i.e., <script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>

or.... what's the error message you are receiving?

MSheridanMSheridan

Yes. I have playing around with it for awhile and I still keep getting a blank screen??? Here's the code I entered:

Code:

<html> 
<head> 
<script src="/soap/ajax/9.0/connection.js"> 
</script> 
<script> 
function init () 
{window.parent.location.href="{!URLFOR($Action.Banking_Svs_Research_Req__c.New, Banking_Svs_Research_Req__c.Id ,[retURL= URLFOR( $Action.Banking_Svs_Research_Req__c.New, Banking_Svs_Research_Req__c.Id)], true)}}"; 
function redirect() { 
parent.frames.location.replace("/{! Banking_Svs_Research_Req__c.Id }/e—retURL=%2F{!Banking_Svs_Research_Req__c.Id}&00NT0000000iTK0={!Case.OwnerFullName}&00NT0000000iTuS={!Case.SuppliedPhone}&save=x") 
} 
redirect(); 
</script> 
</head> 
<body onload="init()"> 
<p>&nbsp;</p> 
</body> 
</html>


 I just want the owner name and phone number to be piped in when they hit new.

Greg HGreg H
When you call the init function on the page load you can send the person directly to the new screen for your custom object with the parameters you want auto-filled in the string (URL).
Code:
parent.document.location.href="/ZZZ/e?retURL=%2F{!Banking_Svs_Research_Req__c.Id}&00NT0000000iTK0={!Case.OwnerFullName}&00NT0000000iTuS={!Case.SuppliedPhone}";

Where "ZZZ" is the Id prefix for your custom object.
-greg

 
sapsap
hi, I am able to prepopulate fields using current record values like parent.frames.location.replace("/006/e?retURL=%2F006%2Fo&RecordType=012500000009ELe&opp4={!Permits_Wells__c.Account__c}") } but now my requirement is to populate a standard field 'account name(acc2)'with a temporary variable 'name1' using name1="xxxx"; parent.frames.location.replace("/001/e?retURL=%2F001%2Fo&acc2=name1") } I tried using this but this is not working. Is there any problem with the syntax. Any help is appreciated. thanks in advance.