Dear fellow Salesforce experts,

I am building a lightning component where I am using a form with fields in order to create multiple records.

I am already able to create multiple opportunity records in my database but I am not able to create multiple temporary opportunity records yet. I want to first create a list of temporary opportunity records 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:


<!-- 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 temporary records-->
<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">
       <th scope="col"><span class="slds-truncate">Name</span></th>
       <th scope="col"><span class="slds-truncate">Child Deal Size</span></th>
   <aura:iteration items="{!v.newChildOpportunities}" var="opportunity">
     <td><ui:inputCurrency aura:id="childAmount" value="{!v.childDealSize}"/></td>    


    createChildOpportunitieslocally: function(component, event, helper) {
      var i=0;
        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

2 Answers 2


For creating dummy records on client side, it is best to use a JSON record:

inside the component markup:

<aura:component >
<aura:attribute name="newItem" 
                default="{'sobjectType': 'myCustomObject__c',
                         'Name': '',
                         'myField__c': 'value',
                         'isTrue__c': false }"/>

inside the contoller:

var strNewItem ='{"sobjectType": "myCustomObject__c","Name": "","myField__c": "value","isTrue__c": false }';
var newItem = JSON.parse(strNewItem);
component.set("v.newItem", newItem);
  • Dear Itai, thank you very much for your answer! If I understand your code correctly this will create one "dummy record", right? Do you know if it is possible to create a list of these "dummy records"? I plan to have fields for one opportunity. Then if someone clicks a "split" button, there should be e.g. 5 new sets of fields (name, amount) for the child opportunities. I am very glad that you are helping me out! Let me know if my description is unclear or if you need more information to help me out. All the best, Paul
    – Paul
    Jul 13, 2016 at 13:09
  • Yes - this code will create one record, you can very easily create a list of records. I do not understated what you are trying to achieve with the record split. Jul 14, 2016 at 9:21
  • A Use Case example why i want to split the record in many: A customer has the opportunity to buy 500 pills right now or 100 pills over the next 5 months. Therefore the admin can split the 500 pills opportunity in 5 times 100pills opportunities for July until November. Is this example plausible to you?
    – Paul
    Jul 14, 2016 at 11:27
  • I understand, you can handle list of objects if you add the attribute: <aura:attribute name="items" type="myCustomObject__c[]" /> then on the controller side, after creating a JSON object - add it to the list: var items = component.get("v.items"); items.push(newItem); component.set("v.items", items); Jul 17, 2016 at 5:30

There is no means for creating temporary records in Salesforce apex.

  • 1
    There is a form with fields that will create an opportunity. In some cases this opportunity will be split in several child opportunities. These should be editable for admins before they get saved. Therefore I need to have a "temporary" list of these records that can be edited before they get inserted into the database. We used this concept with Visualforce Pages which was working fine. Now we are building this feature with Lightning components. I don't want to create these temporary records with Apex but with Aura.
    – Paul
    Jul 13, 2016 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.