@Khan Anas - Posted is my code Accountid is not populating... only lookup fields need to prepopulate it.. but not for other fields. Could you corect my code
When using lightning:inputField for the fields if type ‘reference’ (look up), lookup search does not load the modal for the first time. It works fine after we reload the page
@Valli Did you get your answer? I am creating new record using <lightning:recordEditForm> and i am not able to populate lookup field onload finction. I tried below things but both are not working: 1.
@Mrial Sharma replace "00842156" with the case Id instead of case number replace component.find("caseLookup").set("v.value", "00842156"); with component.find("caseLookup").set("v.value", "<CaseId>");
Hi Valli,
Greetings to you!
You can use the below code:
Replace recordId with your Case Id in above example.
Please refer to the below link with a similar discussion which might help you further.
https://salesforce.stackexchange.com/questions/215218/lightningrecordeditform-not-populating-lookup-fields
https://salesforce.stackexchange.com/questions/219142/how-can-i-pre-populate-a-lookup-field-in-lightninginputfield
https://developer.salesforce.com/forums/?id=9060G0000005ZhkQAE
http://peterknolle.com/lightning-record-edit-form/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks and Regards,
Khan Anas
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="sid" type="String"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="parentId" type="String"/>
<lightning:recordEditForm aura:id="divisionCreateForm" recordId="{!v.recordId}" objectApiName="customobject_c"
onsubmit="{!c.handleSubmit}" onload="{!c.handleOnload}">
<div class="slds-size_1-of-2">
<div class="slds-m-around_x-small">
<lightning:inputField aura:id="lookup" fieldName="Account__c"/>
</div>
</div>
<div class="slds-align_absolute-center slds-m-top_medium">
<lightning:button variant="brand" type="submit" name="save" label="Save" / >
</div>
</lightning:recordEditForm>
</aura:component>
=====================
({
doInit : function(component, event, helper) {
},
handleOnload : function(component, event, helper) {
var parentId = component.get("v.parentId");
// requires inputFields to have aura:id
component.find("lookup").set("v.value", parentId);
},
handleSubmit : function(component,event,helper){
helper.createDivision(component,event);
},
})============
({
createDivision: function(component, event) {
var s = component.get("v.sid");
var enteredFields = event.getParam("fields");
console.log("enteredFields JSON:: "+JSON.stringify(enteredFields));
var JsonString = JSON.stringify(enteredFields);
var createAction=component.get("c.createDivision");
createAction.setParams({
"newdivisionJSON":JsonString
});
createAction.setCallback(this,function(response){
var state=response.getState();
if(state=='SUCCESS'){
console.log('success');
s = response.getReturnValue();
console.log(s);
component.set("v.sid",s);
var evt = $A.get("e.force:navigateToSObject");
console.log("navEvt==="+evt);
evt.setParams({
"recordId": s
});
evt.fire();
console.log('event fired');
}
else{
console.log('error');
}
});
$A.enqueueAction(createAction);
},
})
When using lightning:inputField for the fields if type ‘reference’ (look up), lookup search does not load the modal for the first time. It works fine after we reload the page
If know issue ..
https://success.salesforce.com/issues_view?id=a1p3A000000mDV2QAM
https://success.salesforce.com/ideaView?id=0873A000000E9xzQAC
Refer this code . *"0037F00000XXXXXXXX" should be recordId you need
Did you get your answer?
I am creating new record using <lightning:recordEditForm> and i am not able to populate lookup field onload finction.
I tried below things but both are not working:
1. 2. Controller:
Please help me here, I can do it using custom component but i want to use this.
replace "00842156" with the case Id instead of case number
replace component.find("caseLookup").set("v.value", "00842156"); with component.find("caseLookup").set("v.value", "<CaseId>");