I need to create a custom lightning component(exact same as layout - Object Name - Rider) and add it on object actions(Object name - Order) . On click of button, the lightning component should pop up. I have done till here.
problem statement
some set of fields should be pre populated from (object name - Population). Here i need to pass the current objectid(orderId) and query from population object and prepopulate on custom component like
Rider.name = population.name
and Rider.Phone = population.Phone
cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="RFO_OrderController">
<aura:attribute name="orderRecord" type="Order" />
<aura:attribute name="recordId" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:recordForm objectApiName="Contact"
layoutType="Full"
targetRecord="{!v.account}"
columns="2"
aura:id="test"/>
</aura:component>
controller.js
({
doInit : function(component, event, helper){
var orderId = component.get("v.recordId");
var action = component.get("c.getOrderDetails");
action.setParams({
"orderId" : orderId
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
//following hardcode is also not working.
component.set("v.firstname", 'test');
//how to setup value from query
}
});
$A.enqueueAction(action);
},
})
public class RFO_OrderController {
@AuraEnabled
public static Order getOrderDetails(String orderId){
population__C pop = [SELECT Id, Name, OrderNumber, ContractId, Type, AccountId, RFO_PriceClassification__c,
RFO_LeaseTerms__c, RFO_LeaseRate__c, RFO_Commodity_lookup__c, RFO_Quantity__c,
RFO_ReportingMarks__c, RFO_RunningNumbers__c, RFO_CarType__c
FROM population__c where Id = :orderId];
System.debug('pop :'+pop );
return pop ;
}
}