function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MisbahTehseen Parathanalli 3MisbahTehseen Parathanalli 3 

Can anybody help me with a lookup field in a form to create a record in lightning component?

Can anybody help me with a lookup field in a form to create a record in lightning component?
i am creating a record by taking input from a form using lightning which has one lookup to the user record, i want help with that field....help needed with the same field....
Thanks in advance
 
Meghna Vijay 7Meghna Vijay 7
Hi Misbah,
There are two ways to do it:-
1) Lightning data service , here's a link to it:-
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_save_record.htm
2) Lightning:recordEditForm
https://developer.salesforce.com/docs/component-library/bundle/lightning:inputField/documentation
Hope it helps, if it does mark it as solved.
Thanks
MisbahTehseen Parathanalli 3MisbahTehseen Parathanalli 3
Hi Meghna,
Thanks for replying .... i have created the form and also able to save a record, but my issue is lookup field to the user object.  Do you know any solution for this.
Manoj Maraka 18Manoj Maraka 18

Hi Misbah,
Are you using lightning:recordEditForm? If not, can you add code that you are using?

Meghna Vijay 7Meghna Vijay 7
HI Misbah,
Do you have a field on that custom object which is lookup to user ? If yes, then you can use <lightning:inputField FieldName = "Field API Name"/> in lightning:recordEditForm
Thanks
 
MisbahTehseen Parathanalli 3MisbahTehseen Parathanalli 3
Hi Manoj,
Below code i am using inside lightning:layout tag
                    <form class="slds-form slds-form_horizontal">         
                        <lightning:input aura:id="itemform" label="First Name"
                                         name="itemname"
                                         type="input text"
                                         value="{!v.newUser.First_Name__c}"/>
                        <lightning:input aura:id="itemform" label="Username"
                                         name="itemname"
                                         type="input text"     
                                         value="{!v.newUser.Username__c}"/>
                       <lightning:input aura:id="itemform" label="Manager's Email"
                                         name="itemname"
                                         type="email"
                                         value="{!v.newUser.Manager_Email__c}"/>
                        <lightning:input aura:id="itemform" label="Copy profile from"
                                         name="itemname"
                                         type="input text"
                                         value="{!v.newUser.Model_User__c}"/>
                        <lightning:input aura:id="itemform" label="Manager's Email"
                                         name="itemname"
                                         type="email"
                                         value="{!v.newUser.Manager_Email__c}"/>
                        <lightning:input aura:id="itemform" label="Copy profile from"
                                         name="itemname"
                                         type="input text"
                                         value="{!v.newUser.Model_User__c}"/>
                           </form>

 
MisbahTehseen Parathanalli 3MisbahTehseen Parathanalli 3
Hi Meghna,
what all attributes can be added into it?

thankyou
Meghna Vijay 7Meghna Vijay 7
Hi Misbah,
In <lightning:inputField FieldName = "FieldName API (e.g. User__c)" > and for more information you can see this link:-
https://developer.salesforce.com/docs/component-library/bundle/lightning:inputField
https://developer.salesforce.com/docs/component-library/bundle/lightning:inputField/specification
Hope it helps, if it does mark it as solved.
Thanks