You need to sign in to do that
Don't have an account?
vi
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
<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)}";
alert("Account ID = "); //this works
this.parent.location.href = "{!URLFOR($Action.Account.View, Account.Id)}";
}
</script>
</head>
<body onload="init()">
<p> </p>
</body>
</html>
</script>
</head>
<body onload="init()">
<p> </p>
</body>
</html>
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.