1

I am new to lightning. I am inserting list of contacts in aura iteration with account lookup. I made custom component for searching account, which works fine. But i also need to give option to create new account as well. Initially i made one link inside lookup field and used "force:create", but i was going back to account detail page. And my component is getting called from a button which is on contact detail page. So i made another column for creating account and taking accounts input in a custom component. I am able to create account, but not sure how to set attribute for my lookup comp.

in New Account column i am just calling new model for creating account. My model code to crate account is outside the iteration. I am not sure how to set accountId in aura iteration, which i create outside.

Any help would be appreciated. If any one has implemented anything like this.. I just need to give option to select an account or crate an account, if account is not there.

thank you every one for your comments. I was able to make some progress but still not able to complete.

<aura:iteration items="{!v.newConList}" var="con">
 <c:customLookup objectAPIName="account" IconName="standard:account" selectedRecord="{!con.AccountId}"/>

when account is created outside loop. i know the index and i am setting that accountId with newly created account. But its not rendering that attribute i guess, and not showing any selected account.

I also tried creating that comp again like this, but still not working

$A.createComponent(
                        "c:customLookup",
                        {
                            "objectAPIName":"account",
                            "IconName":"standard:account",
                            "selectedRecord":createdAccount
                        },
                        function(newCard, status, errorMessage){
                            if (status === "SUCCESS") {
                                var body = component.get("v.body");
                                body.push(newCard);
                                component.set("v.body", body);
                            }
                            else if (status === "INCOMPLETE") {
                                console.log("No response from server or client is offline.")
                            }
                                else if (status === "ERROR") {
                                    console.log("Error: " + errorMessage);
                            }
                        }
                    );

Can i set attribue "accountid" of customLookup component. I have added accountId in newConList. And its also showing in log. But not rendering the component again.

6
  • Are you using lightning:overlayLibrary to create modal? Dec 11, 2018 at 14:19
  • @PranayJaiswal no i am not using that. i am using simple "slds-modal__container" classes.
    – Manohar
    Dec 11, 2018 at 14:23
  • I am not sure how to set accountId in aura iteration, which i create outside. -- do you have the accountId of the newly created account in your component?
    – Jayant Das
    Dec 11, 2018 at 17:28
  • yes, i have account var in attribute. Right now i have only one account attribute for all the iteration. I don't have list of account.
    – Manohar
    Dec 12, 2018 at 4:52
  • please share your code Dec 12, 2018 at 6:39

0

You must log in to answer this question.