You need to sign in to do that
Don't have an account?
Pass Opportunity recordId on a Lighting Component to a VF page that open with ui: button - press
Hi,
I have a Lightning Component on the Opportunity detail page that display button when press it opens a VF page.
The VF page is a form to complete to create a record on a custom object Fact_Finder__c which has a master-detail relationship with Opportunity.
I need to pre-populate the Opportunity Name on the VF page from the Opportunity recordId on the Lightning Component and when the Submit button is selected I need to go back to the Opportunity detail page.
I have looked intensively on forums and documentation but could not figure it how to do it.
My current working codes are as following. I have simplified it and did not put much style. The original code display many buttons on the Lightning component and my VF page (form) has a lot of input fields.
My component which capture the Opportunity recordId:
The oppName is what I need to capture (based on the Opportunity recordId) to pre-populate my form.
Any idea?
Thank you in advance for your help.
Sylvie
I have a Lightning Component on the Opportunity detail page that display button when press it opens a VF page.
The VF page is a form to complete to create a record on a custom object Fact_Finder__c which has a master-detail relationship with Opportunity.
I need to pre-populate the Opportunity Name on the VF page from the Opportunity recordId on the Lightning Component and when the Submit button is selected I need to go back to the Opportunity detail page.
I have looked intensively on forums and documentation but could not figure it how to do it.
My current working codes are as following. I have simplified it and did not put much style. The original code display many buttons on the Lightning component and my VF page (form) has a lot of input fields.
My component which capture the Opportunity recordId:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"> <aura:attribute name="FFform" type="String" default="Fact Finder Form" access="global" /> <aura:attribute name="recordId" type="Id" /> <div class="FFbuttons"> <div aria-labelledby="FFformB"> <fieldset class="slds-box slds-theme--default slds-container--fluid"> <legend id="FFform" class="slds-text-heading--small">Fact Finder Forms</legend> Opportunity id {!v.recordId} <form class="slds-form--inline"> <div class="slds-form-element"> <ui:button label="Residential Landlord" press="{!c.openResidentialform}" /> </div> </form> </fieldset> </div> </div> </aura:component>Client side Controller:
({ openResidentialform: function(component, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url": "/apex/ResidentialForm" }); urlEvent.fire(); },VF page:
apex:page standardcontroller="Fact_Finder__c" extensions="ResidentialFormCtrExt" showHeader="false" sidebar="false" > <style type="text/css"> .buttonsubmit { width: 200px; font-size: 150% !important; background:#E9EEF2 !important; } .buttoncancel { width: 200px; font-size: 120% !important; background:#E9EEF2 !important; } </style> <apex:form style="width:800px; text-align:center; margin:auto;" enctype="multipart/form-data" > <apex:pageMessages /> <apex:pageBlock title="Residential / Landlords Fact Finder" > <apex:pageBlockButtons location="bottom" > <apex:commandButton action="{!saveFF}" value="Submit" styleClass="buttonsubmit" /> <apex:commandButton action="{!cancel}" value="Cancel" styleClass="buttoncancel" /> </apex:pageBlockButtons> <apex:outputPanel layout="block"> <apex:pageblocksection columns="1"> <apex:inputfield value="{!FF.Opportunity_Name__c}"/> <apex:outputfield value="{!FF.Client_Name__c}"/> <apex:inputfield value="{!FF.Date__c}"/> </apex:pageblocksection> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>Controller Server Side:
public with sharing class ResidentialFormCtrExt { @AuraEnabled public Fact_Finder__c FF {get; set;} Public ResidentialFormCtrExt(ApexPages.StandardController controller) { this.FF=(Fact_Finder__c)controller.getRecord(); //FF.Opportunity_Name__c= oppName; public PageReference cancel(){ return null; //new PageReference('/' + oppName); } public PageReference saveFF() { insert (this.FF); return null; //new PageReference('/' + oppName); } }
The oppName is what I need to capture (based on the Opportunity recordId) to pre-populate my form.
Any idea?
Thank you in advance for your help.
Sylvie
For those who face the same problem, this is how I make it works:
Application Component Controller APEX VF Page
Sylvie
All Answers
Try this,
Thanks,
Bala
I have amended the Controller like that:
And add the following to my apex class:
And I get the following message:
Any other thought?
Thanks,
Sylvie
You should replace '[RecordId]' with correct record id value. I just mentioned it for your understanding.
Please change it like this. Thanks,
Bala
Now I got this message: The problem is probably on the Apex page. Could you please have a look above and tell me if I called the id correctly?
Thanks,
Sylvie
For those who face the same problem, this is how I make it works:
Application Component Controller APEX VF Page
Sylvie