1

I have a button that calls a Visualforce page that invokes an Aura app/component via Lightning out. I need to do this because in Lightning we cannot have Actions on list views.

Anyway, for me - sysadmin - it works perfectly. At some point the following Javascript code is executed:

window.parent.location.href = '/lightning/r/Verkoopkans_per_mail__c/' + objectId + '/view';

For me this works. Other users get this error:

This page has an error. You might just need to refresh it. Error in $A.getCallback() [Failed to set the 'href' property on 'Location': The current window does not have permission to navigate the target frame to '/lightning/r/Verkoopkans_per_mail__c/a0r3M00000006gTQAQ/view'.] Callback failed: apex://OpportunityForLWCController/ACTION$getAvailableOppPerMail Failing descriptor: {markup://c:GetOppPerMailWrapper}

When I google for 'The current window does not have permission to navigate the target frame to' I get results for not Salesforce specific same-origin-policy problems. But then it should happen to me as well, right? Those kinds of problems don't depend on profiles/permissions?

The custom object Verkoopkans_per_mail__c + its instance is accessible to other users, they can access it via another route and they have sufficient permissions to view it.

1

It happens because in OpportunityForLWCController.cls your method getAvailableOppPerMail() is throwing some error for non-sysadmin users. Most likely due to failing CRUD/FLS checks. Therefore, the Lightning service responsible for navigation refuses to navigate to the failing page.

Also, if you are embedding a VisualForce page under Lightning Experience, then you should use sforce.one.navigateToSObject(objectId) instead of assigning to window.parent.location.href as described here.

3
  • Thank for for pointing this out to me, I have corrected my code. Though I do not think it is the cause of the error. It reeks like a permission problem and it might have to do with caching. Just before the navigation, the owner of the object is changed to the current user.While testing, I have seen once that after navigation, the owner was not changed yet. I refreshed the page and the owner was changed. This could explain the problem that a non-sysadmin user experiences. May 18 '20 at 9:09
  • @SanderdeJong ah, now I get it. Adjusted my answer per your comment.
    – touzoku
    May 19 '20 at 10:06
  • @SanderdeJong can you add the reference code from OpportunityForLWCController.getAvailableOppPerMail() ?
    – touzoku
    May 25 '20 at 13:50
0

When in lightning I have found that errors can happen with calling new visualforce due to the object id not being available for the new page (that is launching) The new visualforce is relying on that Id being there in the URL. Lightning can have issues with this depending on the context of from where you are launching the new visualforce.

Troubleshoot 1 - Look in the URL area when you get the error. Do you see the object ID in the URL?

Also check - If this is happening in a community then ensure that the page you are calling is also allowed to be in the community.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.