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

Custom Button JavaScript cant see parent window HTML?
I am trying to grab an email address from the parent window when my Custom Button is clicked on a Lead Detail page. But it seems like I am doing something wrong in my JavaScript to get at the parent window's HTML (Lead Detail page). Does anyone know the correct syntax to get the HTML of the Lead Detail page when my JavaScript is invoked?
Here is my code snippet:
var obj = parent.document.getElementsByTagName('td');
Alert(obj.innerHTML);
Whatever I am getting back issnt the HTML of the Lead Detail page. And I have tried different combinations of window.parent, parent.window etc etc with no luck.
thanks in advance.
Can't you just pass the e-mail address to your Javascript as part of the button definition? Why have the Javascript try to go get the whole page, then have to parse through it, etc.; that seems an odd solution.
Best, Steve.
If the Lead has multiple email addresses I want to grab all of them. Is there a way to place a custom button next to each email address and pass in the email it is associated with? I would love to see how if it is possible.
Well, I'm not sure I'm 100% gathering what you're trying to do. But, if your Lead object has two (for example) custom fields: email1, and email2, then you should be able to create a button which can call an s-control or visualforce page and pass along arguments of the form: xxxxxx?e1={!email1__c}&e2={!email2__c}
Your code on the receiving end can then query the parameters and process them as you like.
That's not giving you one button per e-mail address, but perhaps this suffices.
Best, Steve.
Correction, I meant email address. I have a regex for email addresses. This code works locally on my workstation on a test HTML page, but when i load the javascript into my OnClick for my Custom Button, it no longer seems to have access to the Lead Page's HTML. Say I wanted to highlight all email addresses in RED text color... why does my code work on the local workstation but not on SFDC? It comes down to not having access to the Lead Page itself or at least I dont know the correct syntax for accessing the LeadPage.document.body.
Anyone know how to grab that so I can properly run GetElementByID() ?
One of two things...
1) If you're using Visualforce, and it's in an IFRAME, you're completely out of luck. Salesforce runs on server.salesforce.com, while Visualforce runs on server.force.com. Since they're different domains, browser security prohibits accessing the parent object. There is no workaround for this problem.
2) If you're using a custom button (i.e. Setup | App Setup | Customize | Leads | Buttons and Links), please note that the button runs in the same page as the lead detail screen. You do not need to access parent, which should ordinarily be null because there is no parent window to the UI in normal conditions. I wrote a quick button that did work, and it looked like this:
alert(document.body.innerHTML)
I do hope this information helps you resolve your problem. If not, let me know, and I'll see what I can do to provide further help.
Hi,
I'm a code novice and am not sure if my question is answered here already. I've created a custom button to email from the account page, but can't get the "To" field to populate with the email address I have in a custom field: !{!Account.Clinic_Email__c}. Here are some things I've tried:
location.replace('/_ui/core/email/author/EmailAuthor?p2_lkid={!Account.Id}&rtype=00Q&retURL={!Account.Id}&template_id=00X80000001EGNN&p2={!Account.Clinic_Email__c}&p2_mod=1&p5=')
location.replace('/_ui/core/email/author/EmailAuthor?p2_lkid={!Account.Id}&rtype=00Q&retURL={!Account.Id}&template_id=00X80000001EGNN&p2={!Account.Clinic_Email__c}&p5=')
Any suggestions?
Thanks in advance!
I am using a custom button that pops a VF page. After the user is done with interacting with the popup, I'd like to close the popup and refresh the parent page.
As this post indicates, you cannot access the parent window from the popup via javascript. At least not by doing..
window.opener.location.href = window.opener.location.href;
or
window.opener.reload();
Basically, window.opener is null.
Has anyone devised a work around for this?
Thanks
What I've done previously is to instead inject my own watchdog event to check when the window closes. This was when I attempted (successfully) to hijack the Lookup Window functionality for my own nefarious plans. Basically, you have the parent window create a variable for the window, then assign an event handler to it, or watch it periodically for when the window is flagged as closed.
Example: