+ Start a Discussion
nasknask 

SControl to over ride new

Hi I am trying to override New button using S control.

What i am trying to achieve here is open normal salesforce stabdard new page but prepopulate one of the picklist field with profile name.

 

I using this s-control.

 

<html>
<head>
<script src="/soap/ajax/13.0/connection.js">
</script>
<script>
function init()
{
var idVal = ( (window.parent.location).toString() );

idVal = idVal.split('retURL=%2F')[1].substring(0,15);

//alert(idVal.length);
var profile="{!$Profile.Name}";
var hstring = "/a0V/e?retURL=%2Fnooverride=1&a0V&00NW0000000iiaV="+profile;
if(idVal.length ==7)
{
alert(idVal.length);
this.parent.location.href =hstring;
}

}
</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>

 

But the problem is this is ending up with blank white page. but the same URL which i am trying to create works fine with a custom button. if i try using scontrol & then overeride New button its ends up in blank screen.

 

 

 

Thanks

Ashok

Best Answer chosen by Admin (Salesforce Developers) 
nasknask

I was able to resolve it . The nooverride parameter should be decalred in the end instead of first .

All Answers

SfdcStevenSfdcSteven

You're using an scontrol, which is your first problem.  If you use visualforce you won't get the javascript error that's causing the init() function to die

 

-Steven

nasknask

I was able to resolve it . The nooverride parameter should be decalred in the end instead of first .

This was selected as the best answer