You need to sign in to do that
Don't have an account?
steeeeveeeeee
Refreshing Salesforce page from Embedded Visualforce page Problem
My question is based on this and other threads which have solved this problem:
However in these other threads, they managed to have solved the problem window.top.location.href = "{!standardobject.id}". This reloads the same page but however loses the window placement which is kept by a refresh. I've tried using window.top.location.refresh() in the same context but to no avail.
Is there another way of refreshing the parent salesforce page from a visualforce page?
Thanks in advance
So I decided to write up a quick test page to demostrate whether it should work or not and it works for me. I'm not sure if this is exactly what you're looking for but feel free to copy this and load it into your sandbox to test it.
NOTE: I tried this in Chrome and IE9 and both worked perfectly.
This page is loaded by going to the URL: https://YOUR_ORG/apex/ScrollLockTest?scroll_pos=5000 (if your page name is ScrollLockTest)
the param scroll_pos will tell the page where to scroll to when loaded
The controller:
The VF Page:
A couple things to note:
1) This page currently just checks for the existence of a page position param. I added the javascript method to save the param when reloading but you can take it from there.
2) I used a page block to render the script tag if the param was present. This is just a sloppy quick way to do it so obviously another way would be used for a production app.
Let me know if you have any questions.
All Answers
I'm having trouble understading what you're trying to do. I think I get that you have an embedded VF page within a standard page layout and you want to reload the standard layout from within the controller of your VF page.
Am I right so far?
If so, I don't get what you mean by you "lose window placement". Could you clarify that a little for me?
Yep that's exactly what I'm trying to do. My problem exists with the solutions I've found so far on the board which consists of putting "/+Standard object Id". When you refresh a page while looking halfway through it the window returns to that area. I'm trying to mimic that function
Hmm ok. What about on reload of the page passing the page scroll index as a parameter to the page and then using that to scroll back to that specific area. That was hard to explain so I laid out the steps below.
1) User visits the std page with your VF page built-in
2) When the VF page reloads the window using window.top.href pass an extra param like page_pos (ex. https://na11.salesforce.com/003000000000034Tgfd?page_pos=100
3) When your VF page loads check for the page_pos param. If found use javascript to scroll the page down to the supplied position
Does that make sense?
Thanks for the reply DaveH.
I've tried it and it doesn't work for me (in Chrome) also wouldn't manually setting a value not scale with different records and different layouts? Is there a reason a reload() doesn't work on the page in this aspect or another way to go about this?
So I decided to write up a quick test page to demostrate whether it should work or not and it works for me. I'm not sure if this is exactly what you're looking for but feel free to copy this and load it into your sandbox to test it.
NOTE: I tried this in Chrome and IE9 and both worked perfectly.
This page is loaded by going to the URL: https://YOUR_ORG/apex/ScrollLockTest?scroll_pos=5000 (if your page name is ScrollLockTest)
the param scroll_pos will tell the page where to scroll to when loaded
The controller:
The VF Page:
A couple things to note:
1) This page currently just checks for the existence of a page position param. I added the javascript method to save the param when reloading but you can take it from there.
2) I used a page block to render the script tag if the param was present. This is just a sloppy quick way to do it so obviously another way would be used for a production app.
Let me know if you have any questions.