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
vivi 

Can't obtain Account.Id in scontrol code used to Override Edit button on Account

I have created an scontrol and have set the scontrol as the override for the Edit button.
 
At present I simply want to display an Alert with the Account.Id value, but I do not seem to be able to get the Account.Id value.
 
If i use the line,  alert("Account ID = ");  
Then I get an alert box to pop up and the View page for the account re-displays properly.
 
If I use the line, alert("Account ID = " + {!Account.Id});
Then no alert box is displayed and the View page goes blank. It is as if the Account.Id is nothing/non-existant.
 
How can I display the Account.Id?
 
Thanks.
 
 
Here is the scontrol code:
 
<html>
<head>
<script src="/soap/ajax/8.0/connection.js">
</script>
<script>
function init()
{
var s
alert("Account ID = " + {!Account.Id}); //this does not work
alert("Account ID = "); //this works
this.parent.location.href = "{!URLFOR($Action.Account.View, Account.Id)}";
}
</script>
</head>
<body onload="init()">
<p>&nbsp;</p>
</body>
</html>
Doug ChasmanDoug Chasman
Try this instead:

alert("Account ID = {!Account.Id}");

The value of a merge field expression like {!Account.Id} does not include the javascript specific string delimiters because we have no way of knowing how you intend to use the value. Essentially your js was evaling to someting like:

alert("Account ID = " + 001x000000000);

and I expect that you did not notice the resulting js script error.
vivi
That worked. Thanks
ClintProdClintProd
This isn't working for me when I override the new button for a custom object related list. I have a custom object related list on my contact page and have overridden the new button for that list, but in the s-control, when I try to use merge fields such as {!Contact.Id} or {!Account.Id}, no value is presented. Am I doing something wrong?