+ Start a Discussion
StefanStefan 

S-Control to Override New Account button

Can anyone help with the code for a new button to override the Account tab New Account button.
 
I am looking to populate a custom Division list field on the Account with the users division.
NaishadhNaishadh
Hope following S-Control will help....
 
<script>
 
newUrl = '{!URLFOR(!$Action.Account.New, null, [ accid=$Request.accid, retURL= URLFOR($Request.retURL,null,null,true) ] , true)}';
 
var cancelUrl = '&cancelURL=/';
cancelUrl += '001/o';
 
newUrl += cancelUrl;
window.parent.location.href = completeUrl;
</script>
StefanStefan
Thanks for the S-Control, unfortunately I am getting an error message:
 
Error: Incorrect parameter for function not(). Expected Boolean, received Text
 
with $Action.Account.New highlighted in the below.
 
Also could you tell me how can prepopulate a custom field on the new Account, believe the field name is: 00N40000001kkrc and the source is {!$User.Division}
 
Code:
<script>
 
newUrl = '{!URLFOR(!$Action.Account.New, null, [ accid=$Request.accid, retURL= URLFOR($Request.retURL,null,null,true) ] , true)}';
 
var cancelUrl = '&cancelURL=/';
cancelUrl += '001/o';
 
newUrl += cancelUrl;
window.parent.location.href = completeUrl;
</script>

 
NaishadhNaishadh
Hi, try this one.
<script>

var newUrl = '{!URLFOR($Action.Account.New , null, null, true)}';

var cancelUrl = '&cancelURL=/';
cancelUrl += '001/o';

newUrl += '&00N40000001kkrc={!$User.Division}';

newUrl += cancelUrl;

newUrl += '&retURL=$Request.retURL';

window.parent.location.href = newUrl;
</script>
StefanStefan
Wonderful Naishadh, worked perfectly.
 
Now all I need to understand why it's working.... What the script does ...
 
Incidentally if I want to add other fields, is it just a case of adding additional lines as below, which seems to work OK:
 
Code:
<script> 

var newUrl = '{!URLFOR($Action.Account.New , null, null, true)}'; 

var cancelUrl = '&cancelURL=/'; 
cancelUrl += '001/o'; 

newUrl += '&00N50000001bNbo={!$User.Division}'; 

newUrl += '&00N50000001YaTQ=Test'; 

newUrl += cancelUrl; 

newUrl += '&retURL=$Request.retURL'; 

window.parent.location.href = newUrl; 
</script>

 
 
 
TCAdminTCAdmin
Hello Stefan,

I have a walk through of building a custom link/button that might give you an idea of how passing data through the URL is possible. If you have other questions then please let me know. There are also a couple solutions in the SF system on creating records through custom links but I felt mine gives more information.

... I forgot to let you know the walk through is on my site :smileyhappy: You can go to my site and click on the solutions tab to get the information.


Message Edited by TCAdmin on 07-08-2008 10:08 AM
StefanStefan
Could you post a link to your walk through, sounds interesting
TCAdminTCAdmin
Stefan,

This will take you right to it: http://www.crmsetup.com/solutions.htm