You need to sign in to do that
Don't have an account?
Display Input Fields on Page and when user fills the data ,It should be saved and navigate to record id of Opportunity
I am able to pass the record id into lightning-component(From Vf page) ,but in the output page i am just getting Empty Form without any data populating .
I have seen that in console i am getting the Opportunity Id,But why data is not populating in input fields
Visualforce-Page :
<apex:page standardController="Opportunity" extensions="PassingParaFromVfPageToCmp">
<apex:includeLightning />
<div id="LightningCompContainer" /> <!--Used to display lightning component-->
<script>
$Lightning.use("c:EnrollemetFormApp", function() {
$Lightning.createComponent("c:EnrollemetForm", {
OppIdfromVfPage:"{!JSENCODE(Opportunity.Id)}"},
"LightningCompContainer",
function(cmp) {
});
});
</script>
</apex:page>
Controller Method :
public class PassingParaFromVfPageToCmp {
public Id oppId;
public PassingParaFromVfPageToCmp(Apexpages.StandardController stdcontroller) {
oppId = Apexpages.currentPage().getParameters().get('id');
system.debug('OPPPPP' +oppId);
}
}
Aura : Component :
<aura:component controller="EnrollementFormCmp" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
access="global" >
<b> Details </b>
<aura:attribute name="OppIdfromVfPage" type="string"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="Opp" type="Opportunity" default="{'SobjectType' : 'Opportunity'}"/>
<div class="slds-p-around_Small">
<lightning:recordEditForm objectApiName="Opportunity"
recordId= '{!v.recordId}'>
<lightning:messages />
<lightning:inputField fieldName="Name" value="{!v.Name}" />
<lightning:inputField fieldName="Actual_Cost__c" value="{!v.Actual_Cost__c}"/>
<lightning:inputField fieldName="Requested_For_Loan_Assistance__c" value="{!v.Requested_For_Loan_Assistance__c}" />
<lightning:inputField fieldName="Account.Name" value="{!v.Account.Name}"/>
<lightning:inputField fieldName="Discount__c" value="{!v.Discount__c}" />
<lightning:inputField fieldName="Batch__c" value="{!v.Batch__c}" />
<lightning:inputField fieldName="Course_Interest__c" value="{!v.Course_Interest__c}"/>
<center>
<lightning:button variant="brand" label="Save" title="Brand action" />
</center>
</lightning:recordEditForm>
</div>
</aura:component>
Js.Method :
({
doInit : function(component, event, helper) {
var oppFromVfPage =component.get('v.OppIdfromVfPage');
console.log('aaaaaaaaa'+ oppFromVfPage);
var action = component.get("c.GetOpportunityDetails");
action.setParams({ currentOppId : oppFromVfPage });
$A.enqueueAction(action);
}
})
Aura-Enabled Method :
public class EnrollementFormCmp {
@AuraEnabled
public static void GetOpportunityDetails(Id currentOppId) {
Opportunity opp = [SELECT Actual_Cost__c, Id,
Requested_For_Loan_Assistance__c,
Account.Name,
Discount__c,
Batch__c,Course_Interest__c FROM Opportunity where Id =:currentOppId ];
}
}
Note : Vf-page is being called from cutom button from Opportunity Detail page . Can any one help me how to solve this issue
You have to set the recordId to load the record edit form:
Change the doInit method like below and try:
No need of apex class and call back functions to load the date in UI.
Also add the below highlighted chanes in compnent:
Thanks,
Maharajan.C
Hi,
Please make this update this method like the below i.e. change return type
and change your input like the below
Please mark it as the best answer if your queries are solved.
Thank You