0

How to Implement Batch Data Entry and Quoting via a Button After Uploading Product Details?

**Quotes Table Fields:**  
- **'Customer'**: Linked to the Customer table  
- **'Quote Number'**: Auto-generated number  
- **'Quote Date'**:  
- **'Quote Validity Period'**:  
- **'Quote Batch Number' (Text)**: Batch number  
- **Subtable**: Positions (one-to-many relationship already exists)  

**Positions Subtable Fields:**  
- **'Material Code' (Text)**:  
- **'Specification Model' (Text)**:  
- **'Description' (Text)**:  
- **'Quantity' (Number)**:  
- **'Tax-Included Unit Price' (Number)**:  
- **'Quote' (Reference to Quotes)**: Linked to the Quotes table.  
- **'Total Price' (Formula, Optional)**: Formula = `'Quantity' * 'Tax-Included Unit Price'`.  

**Import Table Fields:**  
- **'Material Code' (Text)**: Material code.  
- **'Specification Model' (Text)**: Specification/model.  
- **'Product Name' (Text)**: Product name.  
- **'Latest Version' (Text)**: Latest version.  
- **'Quantity' (Number)**: Quantity.  
- **'Tax-Included Unit Price' (Number)**: Tax-included unit price.  
- **'Quote Batch Number' (Text)**: Batch number.  

**Add a new button to the Quotes table:**  
- **Button Name**: "Bulk Upload Quote Details List"  

**Functionality upon clicking the button:**  
1. Query the value of the **'Quote Batch Number' (Text)** field in the Quotes table. If records matching this value are found in the **'Quote Batch Number'** field of the Import table,  
2. Copy all matching records from the Import table to the **Positions** subtable of the current Quotes table.  

**Field Mapping:**  
- **Positions'Material Code'** ↔ **Import table's 'Material Code'**  
- **Positions'Specification Model'** ↔ **Import table's 'Specification Model'**  
- **Positions'Description'** ↔ **Import table's 'Product Name'**  
- **Positions'Quantity'** ↔ **Import table's 'Quantity'**  
- **Positions'Tax-Included Unit Price'** ↔ **Import table's 'Tax-Included Unit Price'**  

This ensures seamless batch import of quote details while maintaining data consistency. 🚀

4 replies

null
    • Fred
    • 13 days ago
    • Reported - view

    You can try something like:

    let t := this;
    let importRecs := select ImportTable where 'Quote Batch Number' = t.'Batch Number';
    for import in importRecs do
        create Positions.(
            Quote := t;
            'Material Code' := import.'Material Code'
        )
    end
    

    You said the button would be in the Quotes table so it is written from that perspective.

    Line 1: puts the current Quote record in a variable.

    Line 2: finds all records in Import Table (make sure to put the actual name of the table) where the Quote Batch Number matches the current Quote record Batch Number and puts it in a variable

    Lines 3 - 8: starts a for loop that goes through each record from line 2 and,

    1) creates a new record, line 4, in the Positions table

    2) then links, line 5, the new Positions record to the current Quote record using the variable from line 1.

    3) copies the data, line 6, from the 'Material Code' field of the ImportTable record to the 'Material Code' field of the new Positions record.

    You can add more lines some testing to make sure the linking works.

    There is no checking of anything so it will keep making new records on every press of the button.

      • lixingyang
      • 11 days ago
      • Reported - view

       

      Thank you for your detailed response! I need your help again.

      Contacts table fields:

      • 'Customer Name' (Text)

      • 'Customer Number' (Text)

      New fields added to Positions subtable:

      • 'Customer Name-B' (Text)

      • 'Customer Number-B' (Text)

      • 'Quote Number-B' (Text)

      I want to populate the values of 'Customer Name' and 'Customer Number' from the Contacts table referenced by the Quotes table, along with the value of the 'Quote Number' field, into each newly created record in the Positions subtable.

      To achieve this, I added the following code to the After Change trigger of the Positions table:

      swift

      if 'Quantity' != null then
          this.('Quote Number-B' := Quotes.'Quote Number');
          this.('Customer Name-B' := Quotes.Contacts.'Customer Name');
          this.('Customer Number-B' := Quotes.Contacts.'Customer Number')
      end

      However, only the 'Quote Number-B' field is being populated with values, while the other two fields remain empty.

      • John_Halls
      • 11 days ago
      • Reported - view

       Not sure but my guess would be that Quotes.Contact is returning an array. Try adding first() to convert this to a record

      if 'Quantity' != null then
          this.('Quote Number-B' := Quotes.'Quote Number');
          this.('Customer Name-B' := first(Quotes.Contacts).'Customer Name');
          this.('Customer Number-B' := first(Quotes.Contacts).'Customer Number')
      end
      

      Regards John

      • Fred
      • 11 days ago
      • Reported - view

       

      Another option, if you don't need a history, is to use the link to quote to just pull the Customer Name/Number.

      In a new formula field you can put:

      first(Quotes.Contacts).'Customer Name')
      

      That way, once the Quotes field gets link it will get the Customer Name/Number.

Content aside

  • 11 days agoLast active
  • 4Replies
  • 39Views
  • 3 Following