5

(NOT SURE, BUT THIS ISSUE MIGHT BE A SALESFORCE BUG OR AT LEAST AN INCONSISTENCY)

I have defined an Action of type "Custom Visualforce" like this

enter image description here

The button for this Action is "◈ Clone" (top right corner)

This opens up a Visualforce Page in a popup an I'm doing some stuff with Javascript. No Custom Apex Controller, only a standard controller used.

enter image description here

When I'm done, I just close the popup via cancel or via the X-bottom on top.

ALL WORKS FINE WITH NO ISSUES AT ALL

The problem starts after the popup is closed when I go on working in Lightning Experience. Then there is an unwanted entry in the browser history. Now when I just navigate back, I do not go to the place I would expect but the popup opens again and the Visualforce Action gets re-executed. This is absolutely not OK.

How can this be prevented? I need the Back-Button just to ignore the popup.

I've tried to kill the entry by JavaScript

https://developer.mozilla.org/en-US/docs/Web/API/Location/replace

Using

history.replaceState(null, "---", '/');

But I can't get rid of the history

UPDATE 1

This issue might not appear in Console Apps as Kris Goncalves stated. I did not verify it. If this is true, I think this is an Salesforce BUG in non-Console Apps

UPDATE 2

Untested idea of a workaround:

  • Use Aura Component instead of VF Page as Action Type
  • Write a wrapper Aura Component
  • Use an IFRAME to host the VF-Page
  • maybe the history is not polluted by the VF-Page
  • OR the Aura Component can clean the history (which the VF-Page can not do itself)
  • testing required
4
  • just a note. This only occurs when using standard navigation in an app. Console navigation apps do not exhibit this behavior. Just another thing to consider in thinking of a workaround. Oct 28, 2021 at 15:56
  • Take a look at this: stackoverflow.com/questions/31492143 You need to switch standard controller actions to remote action or other Ajax kind of thing so that browser doesn't know that you are submitting a form.
    – javanoob
    Oct 29, 2021 at 1:10
  • @javanoob not helpful here. I wrote "No Custom Apex Controller, only a standard controller used". In fact, there is NO APEX Class at all. No Apex functionality is used. Pure Javascript. The reason for this flaw is Salesforce and no my code. I think this is an issue of salesforce an how the have embedded the Action button.
    – Uwe Heim
    Oct 29, 2021 at 10:56
  • @KrisGoncalves so this is probably an issue only salesforce can fix. Only this ugly workaround for non-console comes to my mind: use Lightning Aura compo instead. Inside the aura compo use an iframe. load VF-page there. this might avoid the history. but unsure. maybe the aura compo can clear the history. lots of tests would be required
    – Uwe Heim
    Oct 29, 2021 at 11:00

0

You must log in to answer this question.