You need to sign in to do that
Don't have an account?

Override New Button and pass data
Trying to override the "New System" button (on a custom object called Location) I get an error: Invalid Data
with this Custom S-Control:
<html>
<head>
<script src="/soap/ajax/8.0/connection.js"></script>
<script>
function pInit() {
var url = parent.location.href; //URL accessing sControl
url += "&CF00N80000002ZueH= {!Location__c.Account__c}";
url += "&nooverride=1"; //
parent.location.href = url; //pass full URL to page (refresh)
}
</script>
</head>
<body onload="pInit()">
</body>
</html>
<head>
<script src="/soap/ajax/8.0/connection.js"></script>
<script>
function pInit() {
var url = parent.location.href; //URL accessing sControl
url += "&CF00N80000002ZueH= {!Location__c.Account__c}";
url += "&nooverride=1"; //
parent.location.href = url; //pass full URL to page (refresh)
}
</script>
</head>
<body onload="pInit()">
</body>
</html>
when I change:
url += "&CF00N80000002ZueH= {!Location__c.Account__c}";
into:
url += "&CF00N80000002ZueH= Jansen";
it works.
Can anyone tell me what might be wrong?
Peter
When referencing merge fields, make sure you're enclosing them with double/single quotes.
Is the {!Location__c.Account__c} merge field the Account name or some other text value? My guess is that there my be a problem with special characters (spaces, etc) being included in the URL. If this is the case then you can use the SUBSTITUTE() function to replace the special characters when you insert the merge field.
-greg
it works, which actually is exactly the same data as far as I know.
{!Location__c.Account__c} is indeed the (Master-Detail) Account Name.
Some Account names have spaces, so I tested this
but I get the same error, while this:
works fine.
Message Edited by Peter van Heck on 09-24-2008 10:34 AM
My recommendation is to copy the resulting URL string from the browser address bar for the two code variations and then compare them to see the difference. If I had to make a guess, it could be that {!Location__c.Account__c} is not being retrieved. If this is for a related list item, you may be able to work around the problem by creating a new button, but not overriding the 'New' button. Using the Page Layout editor, assign this button to the Related List removing the default [New] button. That worked for me.
Mike
Try this:
If it still doesn't work, remove the comment from the alert to see exactly what {!Location__c.Account__c} is bringing back :D