You need to sign in to do that
Don't have an account?
How to create multiple local objects with lightning components
Dear Salesforce experts,
I am building a lightning component where I am using a form with fields in order to create multiple opportunities.
I am already able to create multiple opportunities in my database but I am not able to create multiple local opportunities yet.
I want to first create multiple local opportunities that I can display as a list with certain fields that can be manually adjusted.
I very much appreciate help, since I couldn't find any solution although I was searching for it for one week!
Here is my code:
createMultipleOpportunities.cmp
<!-- form with fields that are used to create multiple opportunities, i don't think this code is relevant, therefore not shown here-->
<!--variable that is supposed to generate a collection or array where i can store my new local objects-->
<aura:attribute name="newChildOpportunities" type="Opportunity[]"/>
<!--Button that is supposed to create local opportunities-->
<ui:button label="Create child Opportunities" press="{!c.createChildOpportunitieslocally}"/>
<!--this part is supposed to iterate through all child opportunities, doesn't display them yet-->
<table class="slds-table slds-table--bordered">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">Name</span></th>
<th scope="col"><span class="slds-truncate">Child Deal Size</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.newChildOpportunities}" var="opportunity">
<tr>
<td>{!opportunity.Name}</td>
<td><ui:inputCurrency aura:id="childAmount" value="{!v.childDealSize}"/></td>
</tr>
</aura:iteration>
</tbody>
</table>
createMultipleOpportunitiesController.js
({
createChildOpportunitieslocally: function(component, event, helper) {
var i=0;
for(i=0;i<5;i++){
component.set("v.newChildOpportunity.Name", "child " + i);
component.set("v.newChildOpportunity.Deal_Size__c", 500);
}
},
})
Let me know if you need further information.
Thank you in advance for your help :)!
Best regards,
Paul
I am building a lightning component where I am using a form with fields in order to create multiple opportunities.
I am already able to create multiple opportunities in my database but I am not able to create multiple local opportunities yet.
I want to first create multiple local opportunities that I can display as a list with certain fields that can be manually adjusted.
I very much appreciate help, since I couldn't find any solution although I was searching for it for one week!
Here is my code:
createMultipleOpportunities.cmp
<!-- form with fields that are used to create multiple opportunities, i don't think this code is relevant, therefore not shown here-->
<!--variable that is supposed to generate a collection or array where i can store my new local objects-->
<aura:attribute name="newChildOpportunities" type="Opportunity[]"/>
<!--Button that is supposed to create local opportunities-->
<ui:button label="Create child Opportunities" press="{!c.createChildOpportunitieslocally}"/>
<!--this part is supposed to iterate through all child opportunities, doesn't display them yet-->
<table class="slds-table slds-table--bordered">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">Name</span></th>
<th scope="col"><span class="slds-truncate">Child Deal Size</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.newChildOpportunities}" var="opportunity">
<tr>
<td>{!opportunity.Name}</td>
<td><ui:inputCurrency aura:id="childAmount" value="{!v.childDealSize}"/></td>
</tr>
</aura:iteration>
</tbody>
</table>
createMultipleOpportunitiesController.js
({
createChildOpportunitieslocally: function(component, event, helper) {
var i=0;
for(i=0;i<5;i++){
component.set("v.newChildOpportunity.Name", "child " + i);
component.set("v.newChildOpportunity.Deal_Size__c", 500);
}
},
})
Let me know if you need further information.
Thank you in advance for your help :)!
Best regards,
Paul
I changed Deal_Size__c to Amount, for demonstrative purposes, but you should be able to figure it out from here.
Change out your <tbody> to
and your controller.js to something like