0

Parent window is served from my.salesforce.com domain and the child (pop-up) window is served from another domain, visual.force.com. The functionality is to populate the value the user selects in pop-up back to the parent window. I was using the window.opener to communicate with the parent window, but I get the error message " Domains, protocols and ports must match" in the parent window.

Any idea how this could be avoided? and the values passed from child to the parent?

-Sameer

Sam
  • 1,311
  • 2
  • 23
  • 47

3 Answers3

2

You might be able to hack around this with srcUp function. It's not an official API, blah blah blah but I seem to recall it's used by SF, especially around Service Cloud Console.

http://boards.developerforce.com/t5/Java-Development/Issue-with-javascript-button-within-Service-Console-need-advice/td-p/290171

http://boards.developerforce.com/t5/Visualforce-Development/Getting-quot-Not-Implemented-quot-Javascript-error-on-SrcUp/td-p/361585

https://salesforce.stackexchange.com/questions/5009/open-a-service-console-primary-tab-from-a-custom-component-module (pity the link from techtrekker's comment has expired).

http://salesforcedevbj.blogspot.com/2012/10/custom-links-and-buttons-in-service.html

Sorry, not a real answer, I never had to hack stuff like that... but at least you have some ray of hope to Google for now. Also try cross-posting on salesforce.stackexchange.com?

Community
  • 1
  • 1
eyescream
  • 18,088
  • 2
  • 34
  • 46
  • Thanks for the response. I was not sure How to go about using the srcUp function in my case. I have added some javascript in the home page component which overrides the href on the look up on the standard detail page of account to a VF look up page. In the standard look up page, salesforce have implemented the top.window.opener.lookupPick() function to update the records back in the parent window. Now since in my case the parent window (salesforce.com) and Vf page (.visual.force.com) are served from different domain, I am getting the issue of same origin policy. – Sam May 09 '13 at 16:59
  • 1
    In that case if you're injecting something to the sidebar I believe you could equally inject your homemade srcUp / event listener that could be defined on parent (actually in sidebar) and executed from the popup. http://stackoverflow.com/questions/15582211/javascript http://stackoverflow.com/questions/13042615/allowing. Another thing that comes to mind is ajax proxy but it looks pretty hardcore: http://salesforce.stackexchange.com/questions/9989/how. As I said, i never had to use it, I just kind of know what to Google for if I'll ever have to :/ – eyescream May 09 '13 at 17:27
  • Thanks eyescream. The postmessage works like a charm. This helped a lot. Only thing now is to make sure that the postMessage works fine in IE8. As of now only tested on Chrome. Thanks again! – Sam May 09 '13 at 18:56
  • Awesome! Most of the time it's like that, "you need what to Google for" and then suddenly all works and is easy, eh... Would you consider posting your (anonymized if needed) solution as another answer so others can benefit? Bob Buzzard's VF lookup got lots of attention (http://bobbuzzard.blogspot.co.uk/2011/02/layered-visualforce-lookup.html), maybe you'll be famous too :) – eyescream May 09 '13 at 19:06
  • Bob Buzzard is a legend in salesforce. Yes, you're right I should have known what to google for. But anyways I will share the code in my blog (jungleeforce.wordpress.com) so that it could help anyone who's looking out for this type of functionality. Thanks again eyescream. – Sam May 10 '13 at 04:50
1

Javascript cannot communicate across domains for security reasons, as it breaks the Same Origin Policy.

Not sure it's possible, but you might want to look into seeing if you can make a JSON-P call to a webservice on the parent domain, which sets values on the server-side, which are then read by the parent page.

You can read about JSON-P here:

What is JSONP all about?

Community
  • 1
  • 1
MasNotsram
  • 2,105
  • 18
  • 28
0

I suffered same problem. I think that if you are on salesforce standard edit page(Parent) then create a visualforce edit page(assume page name is Test) same as this page. After that go to object for which you implementing this and edit 'edit' standard button and then you will get ovveride with option select visualforce page Test.

If i m getting wrong understanding of ur question then please let me know....

  • Sameer wanted to overwrite all lookup windows in the system (on both standard & VF pages) to open his custom VF lookup instead of standard one. He could override the edit page but he'd lose lots of the flexibility offered by standard page layouts + he'd have to do it for many objects! – eyescream May 10 '13 at 08:06
  • No problem my skype Id is Ayub.Ansari35...I can give an easy solution.Previously I had worked on Lookup helper project. – Bugkiller May 10 '13 at 09:05
  • eyescream is right. I wanted to use the standard pages(edit, detail, new), but only wanted to override the lookup page as I had referenced that object as look up in many other objects. – Sam May 10 '13 at 09:15