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
MattLMattL 

Overriding New Button results in infinite loop

I'm trying to develop custom code for overloading the New button on a related list. This will populate not just the Contact name (as the standard functionality does), but also populate the Member Status and Group fields from the Contact, automatically.

Code:
<html>
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script language="Javascript">
function replace()
{
parent.document.location.href="/a00/e?00N40000001RC56={!Contact.Name}&00N40000001RC69={!Contact.Member_Status__c}&00N40000001RC64={!Contact.Group__c}";
}
</script>
</head>
<body onload="replace()">
</body>
</html>


Yet every time I click on the button, the first URL it takes me to is the proper one. Then, it reloads the page, loses the values... and then reloads the page again. And continues to just sit there reloading the page. I never actually see the new object dialog show up. Can anyone assist?
 

Ron HessRon Hess
when you override the new button, you really override the new form, so your directing to /a00/e is taking you back to your code, as you discovered.

i think your code can add nooverride=1 to avoid falling into this hole.  check out nooverride in the online help.
MattLMattL
It worked! Thanks so much.

Quick different question, if ya could answer it...
It isn't actually sending the values it should. When the link does appear, all the = with the merge fields disappear.

It first redirects to:
https://na2.salesforce.com/a00/e?CF00N40000001RX56=Test+Testington&CF00N40000001XC56_lkid=003X000000Mo2z3&scontrolCaching=1&retURL=%2F0034000000MX2z3

And then:
https://na2.salesforce.com/a00/e?nooverride=1&CF00N40000001RX56=&CF00N40000001XC69=&CF00X40000001RC64=

Any ideas?
Ron HessRon Hess
not sure if this will help, haven't tried it , but you may want to use the escape() function of javascript to translate
those '&' chars.

something like this

Code:
<html>
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script language="Javascript">
function replace()
{
parent.document.location.href= escape(
 "/a00/e—00N40000001RC56={!Contact.Name}&00N40000001RC69={!Contact.Member_Status__c}&00N40000001RC64={!Contact.Group__c}");
}
</script>
</head>
<body onload="replace()">
</body>
</html>

 

hope it helps.

Message Edited by Ron Hess on 08-06-2007 07:58 PM

Reid MaulsbyReid Maulsby
On the redirect:
 
 
It looks like you're having the same problem as I am, where the variables are not being passed into the URL.  My link is correct, except no values are showing up next to the '=' signs, so my edit screen is showing up completely blank.
 
Did you figure out anything on this?  I'm looking for the same fix.
 
Thanks
Reid
MattLMattL
Unfortunately, I have yet to solve this.
It looks like there's the possibility that this method doesn't work at all, and instead the method to use is the $URLFOR() function.

That's a problem for me, however, as both of the other variables I'm trying to pass are picklists. Using a picklist value inside a formula makes Salesforce.com complain "You must use ISPICKVAL() or CASE()"... which would mean 6-9 if statements for the first variable... and then NESTED inside each of those are 20 more if statements for the second variable... meaning I'd have to write 200 if statements to get this code to work. At this point, we're stuck, and just using the default functionality of the New button. :/
Reid MaulsbyReid Maulsby
I figured out some of this.
 
Check out this thread:
 
It may help with part of your problem, but not totally for the 200 nested IF statements...ouch.
NazeerNazeer
Hi,


I guess this thread is right place to put my question.. I have developed similar kind of link for my use.
But now requirement is to populate picklist value. I am copying a record by clicking button.

0xxx000xxx0xxxx={!Account.Status__c}  //  Status is picklist -This is not working.

All the picklist fields values are not populated in new record.  Any help around this highly appreciated