1

currently on the account ojbect i have a related object that has a list button

/apex/New_Service_VF?pId={!Account.Id}

that runs a VF page.

Now i'm thinking of making a quick action that initialized the VF page, and somehow pass the record id....BUT the it would be a massive rewrite as the object controller is not a standard controller... and the VF page has it's own controller.

So is it possible to create a lightning component that simply passes a record Id to a VF page and starts a VF page?

would this work?

    <aura:component controller="New_Service" implements="force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
      <aura:handler name="init" value="{!this}" action="{!c.newService}"/>
</aura:component>

js controller

({
    newService : function(component, event, helper) {
            var urlEvent = $A.get("e.force:navigateToURL");
            var recordId = component.get("v.recordId");


                urlEvent.setParams({
          "url": 'https://xxxxxxxx--XXXXXXXX.cs41.my.salesforce.com/apex/New_Service_VF?id=' + recordId, 

        });
        urlEvent.fire();
    }
})

This gets me the following error

Read timed out An unexpected error has occurred. Your development organization has been notified.

When i just use

/apex/New_Service?id=' + recordId,

i get the null page error.

All i'm trying to do is fire a VF page and pass the account record ID to it...that's it no more no less. I would use a quick action to fire the VF page (i'm using a quick action to fire this), but that would take a major rewrite of apex code.

solved: I'm a silly and the sandbox has custom setting issues.

0

Best practice would be to use the lightning:navigation helper library component. See the Page Reference examples here, specifically the "Navigate to a Web Page".

If you're VF page is a custom tab, then you can use the Navigation Item Page Type standard__navItemPage as referenced here (with an example on how to use it), or just use the standard_webPage page type for a regular VF page

4
  • So i updated my question i'm wondering if the issue is the URL, because i'm getting the null error in sfdc when it redirects. – ensir Apr 23 '19 at 16:50
  • Not sure what's giving the null error. For what it's worth, force:navigateToURL is an older component event and Salesforce suggests to use lightning:navigation moving forward :-) That's what they say in the official documentation and you can use standard__webPage page type for navigating to the VF page – Brian Miller Apr 23 '19 at 18:52
  • Miler thank you, just found it. the VF page calls on it's controller which calls on a toolingquery class we have which uses custom settings that werent changed from our production org to this sandbox lolol – ensir Apr 24 '19 at 18:05
  • Parity between your sandbox and production, happens all the time! – Brian Miller Apr 24 '19 at 19:42

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.