0

How to create records automatically

Hi!

I’m creating a new App calendar deadlines.

I have the following tables:

1. Customers 
    a. Name
    b. Typology
    c. Accounting

    Customers are divided into 10 different types and can have 2 different types of accounts (quarterly or monthly)

2. Expiry
    a. Name
    b. Date
    c. Type Customer
    d. Accounting Customer

    Expiry may have annual, quarterly and monthly maturities.

Depending on the Typology and Accounting of the Customer I must associate some expiry. To do this I created the table

3. Fulfillment.
    --> 1. Customers
   --> 2. Deadlines
    a. Fulfill (Yes, No)
    b. Date of Fulfill

In this way I create a calendar and the respective tasks.

 

Question.
How to associate Fulfillment to each Customer? In other words, how to fill the Fulfillment table?

I thought I’d create a code 
    - Check the Typology and Accounting of the Customer just entered
    - Create the necessary records in the Fulfillment table by taking only the Expiry related to the Typology and Accounting of that Customer.

What do you think? Is there another better method?

Which code to create?

Thank you

9 replies

null
    • Fred
    • 1 yr ago
    • Reported - view
    webmaster.antonioferriero said:
    Question. How to associate Fulfillment to each Customer? In other words, how to fill the Fulfillment table?

     Are you starting in the Fulfillment table, the Customer table, or a Dashboard?

    What is your work flow? Are you in a Customer record and need to create the fullfillment records? Or do you start in Fullfillment then want to add all Customers?

    Or are you in a dashboard.

    • Web_Namer
    • 1 yr ago
    • Reported - view

    Hi Fred , thank you!

    I have filled the Expiry table 

    I’m in a Customers chart record. 
    I just created a Customer.
    With a button I would like to fill the Fulfillment table like this:
    I check the type of Customer, select the Expiry associated with this type and create the Fulfillment.

    For example. In the Fulfillment table I have the following records (fields divided by "-"):
    1. a. Payment of taxes - b. 30 December - c. Ltd Companies Customers - d. Empty
    2. a. Budget preparation - b. 5 January - c. Ltd Companies Customers - d. Empty
    3. a. Payslip  -  b.16 January - c. INC. Companies Customers - d. Empty
    4. a. Declaration  - b. 7 January - c. All - d. Empty
    5. a. Invoicing - b. 16 January - c. All - d. Quarterly accounting
    6. a. Invoicing - b. 16 February - c. All - d. Half-yearly accounting
    7. a. Invoicing - b. 16 March - c. All - d. Monthly Accounting

    In reality records are much more.

    In the Customers table I created a record with the following fields:
    a. AZName Ltd.
    b. Ltd Companies
    c. Quarterly accounting

    In the record of the Customer AZName Ltd., I click on the button "Create fulfillments" and the code, verifies that it is a capital company and creates, in the table Fulfillments the following records with reference to 2024:
    1. a. Payment of taxes - b. 30 December 2022
    2. a. Payment of taxes - b. 30 December 2023
    3. a. Payment of taxes - b. 30 December 2024
    4. a. Budget preparation - b. 5 January 2023
    5. a. Budget preparation - b. 5 January 2024
    6. a. Declaration  - b. 7 January 2023
    7. a. Declaration  - b. 7 January 2024
    8. a. Invoicing - b. 16 May 2022
    9. a. Invoicing - b. 16 September 2022
    10. a. Invoicing - b. 16 January 2023
    11. a. Invoicing - b. 16 May 2023
    12. a. Invoicing - b. 16 September 2023
    13. a. Invoicing - b. 16 January 2024
    14. a. Invoicing - b. 16 May 2024
    15. a. Invoicing - b. 16 September 2024

    Can you create such a button? With which code?

    • Fred
    • 1 yr ago
    • Reported - view
    webmaster.antonioferriero said:
    Can you create such a button? With which code?

     You can do most things in Ninox.

    My little brain is having a hard time generalizing your workflow. Can you post a sample DB? If not then I'll spend a few more moments trying to understand your structure.

    • Web_Namer
    • 1 yr ago
    • Reported - view

    Thank you Fred ,

    Now I can’t send you DB. Monday I will. Thank you very much.

    • Fred
    • 1 yr ago
    • Reported - view

    in the example you give, is there 15 records in the expiry table for customer AZName Ltd?

    So there is a N:1 relationship between Expiry (many) and customer (one) and a N:N (many to many) between Fulfillment and Customer and N:1 between Fulfillment and Expiry?

    • Fred
    • 1 yr ago
    • Reported - view

    You can try this in button in the Customer table:

    let t := this;
    let selExpiry := (select Expiry);
    let st := 'Society Tipology';
    let neededExpiry := selExpiry['Which company?' = 1 or (var EfS := numbers('Expiry for society');
                count(EfS[= st]) > 0)];
    for loop1 in neededExpiry do
        let xYear := if loop1.'Expiry year' = 1 then
                year(today())
            else
                year(today()) + 1
            end;
        let newFF := (create Filfull);
        newFF.(
            Customer := t;
            Name := loop1.'Expiry Name';
            Data := date(xYear, loop1.'Expiry month', loop1.'Expiry day')
        )
    end
    

    Line 1 creates a variable and stores the current record info.

    Line 2 creates a variable and finds all records in the Expiry table and stores it in an array

    Line 3 creates a variable and put the record info selected in the Society Tipology reference field.

    Lines 4-5 creates a variable that filters the selExpiry array to only those needed.

    Lines 6-18 is the for loop command that uses the array in neededExpiry and:

    Lines 7-11 checks the 'Expiry Year' choice field and if it is 1 then put the current year in the variable xYear. If it is not 1 then it takes the current year and adds 1.

    Lines 12-17 creates a new record in Fillfull and:

    Line 14: links the Customer in Fillfull to the current record in Customer

    Line 15: sets the Name in Fillfull to the current loop Expiry Name

    Line 16: sets the Data field to the date made up of the xYear field and the month and day fields in the current loop Expiry record.

    • Web_Namer
    • 1 yr ago
    • Reported - view

    Thanks Fred ,

    I only answer now because I started studying the code.

    Resolved

      • Fred
      • 1 yr ago
      • Reported - view

      Web Name Good to hear. please mark the post answered if you are happy with the solution. 

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 9Replies
  • 184Views
  • 2 Following