You need to sign in to do that
Don't have an account?
Firas Taamallah 12
How to save multi records on lookup field using LC ?
Lightning component :
Controller JS :
Contact and user haven't been saved - Please note c:reUsableMultiSelectLookup is another lightning component , it's goal : user be able to select multi records on lookup field
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="SaveFormVisitReport" > <aura:attribute name="recordId" type="String" /> <aura:attribute name="selectedLookUpRecords" type="Contact" default="[]"/> <aura:attribute name="selectedLookUpRecords1" type="User" default="[]"/> <aura:attribute name="newRecord" type="Visit_Report__c" default="{ 'sobjectType': 'Visit_Report__c', 'Visit_Type__c':'', 'Contact__c':'', 'User__c':'', 'Account__c':'', 'Comments__c':''}"/> <lightning:recordEditForm aura:id="myform" objectApiName="Visit_Report__c" onsubmit="{!c.handleSubmit}"> <lightning:messages /> <lightning:inputField fieldName="Visit_Type__c" aura:id="type"/> <lightning:inputField fieldName="User__c" aura:id="user"/> <c:reUsableMultiSelectLookup objectAPIName="Contact" IconName="standard:contact" lstSelectedRecords="{!v.selectedLookUpRecords}" label="Contact Name" aura:id="cont"/> <c:reUsableMultiSelectLookup objectAPIName="User" IconName="standard:User" lstSelectedRecords="{!v.selectedLookUpRecords1}" label="Assigned to" aura:id="user"/> <lightning:inputField fieldName="Account__c" aura:id="acc"/> <lightning:inputField fieldName="Comments__c" aura:id="comm"/> <lightning:button class="slds-m-top_small" type="submit" label="Create new"> </lightning:button> </lightning:recordEditForm> </aura:component>
Controller JS :
handleSubmit: function(component, event, handler) { var input1 = component.get("v.selectedLookUpRecords"); var input2 = component.get("v.selectedLookUpRecords1"); component.find('cont').set('v.value', input1); component.find('acc').set('v.value', input2); component.find('myform').submit(); }
Contact and user haven't been saved - Please note c:reUsableMultiSelectLookup is another lightning component , it's goal : user be able to select multi records on lookup field
Your query is answered in this blog,
https://salesforce.stackexchange.com/questions/302998/save-form-lightning-component
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks.
Unfortunately , it's not solved yet ..
To handle saving records on multiple objects, you need to add an apex method and call the method from js controller/helper.