0

Displaying a record in another table

Hello

There is table 1 in which there is table 2, record there are made using the button. 'tab.name' - 'number' -  'group'

In table 3 there is an sub table 5. And I need that if the date in table 1 and in table 3 same, then the record from the fields 'tab.name' - 'number' - 'group' goes to table 5 in the field 'tab.name' - 'number' - 'group'

now the system is set up so that I need to enter the same data in table 5 p in fields  'tab.name' - 'number' -  'group' and the rest will go automatically. That's why I need the record to be automatically displayed in this field, the system will do the rest by itself

18 replies

null
    • Fred
    • 4 mths ago
    • Reported - view
     said:
    now the system is set up so that I need to enter the same data in table 5 p in fields  'tab.name' - 'number' -  'group' and the rest will go automatically. That's why I need the record to be automatically displayed in this field, the system will do the rest by itself

     I don't quite understand what you are saying here?

    Are you trying to show related records from Table5 in Table1 where the Date in Table3 equals the Date in Table1?

    Then you want to change the button on Table1 to create records in Table5 as well as related records in Table3 and Table4?

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       Hello 

      in table2 there are records. And if in table3 I create a day, and on this day in table2 there is a record, it should be displayed in table5

      you helped me to implement this task. that if in table 5 in the necessary three fields to write data and they coincide from the same day with the records in table2, they are automatically displayed. Now it is necessary not to write, but to be displayed by default

      when we used the Formula

      let t := this;
      first((select AllTables)[Date = t.Date and 'Table Name' = t.'Table Name'].'14 value show')

    • Fred
    • 4 mths ago
    • Reported - view
     said:
    in table2 there are records. And if in table3 I create a day, and on this day in table2 there is a record, it should be displayed in table5
    I need to work with tables, no view

    Thanks for a more detailed description.

    Since Table2 and Table3/Table5 are not related then you need to use a view element to show Table2 in Table5.

    This is where using data in related records can be hard to see and thus hard to imagine the coding. To make things easier, I would recommend creating a formula field in both Table2 and Table5 that points to the related Date in Table1 and Table3. One it makes it more obvious what field you can search/filter on. Plus you don't have to follow the chain up everytime you want to use Date.

    Then in a view element it is:

    let t := this;
    select Table2 where Date = t.Date.
    
      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       

      the situation is that in these tables only 3 fields match. and then they pull the necessary information from different tables. table 5 not miror table 2, only a few fields

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       

      let d := format(Date, "DD.MM.YY");
      (select 'Table2')[format(Date, "DD.MM.YY") = d].number

      if ш use this formula, having previously created the 'Date' fields, then in the field it takes data from all the fields from table 2, there are three records. How to make it so that all the records from table 2 are created separately in table 5? I need to solve this issue

      • Fred
      • 4 mths ago
      • Reported - view

      Are you updating the button in Table1? or creating a new button? in which table?

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       

      I created a new field, I thought to add a button, but it creates a record, but when I open a new day, it is empty. 

      I think that is necessary to make it so that, when ia new day is created in table5, it should create the same record from table2, separetly each one, where the values of several fields will be copied

    • Fred
    • 4 mths ago
    • Reported - view
     said:
    I created a new field, I thought to add a button, but it creates a record, but when I open a new day, it is empty. 

    I'm looking at the new DB you uploaded and I can't find any other button besides the one in Table1.

     

     said:
    I think that is necessary to make it so that, when ia new day is created in table5, it should create the same record from table2, separetly each one, where the values of several fields will be copied

    Now that my slow brain has caught up a bit here is a question:

    Will Table5 store different data than Table2? If not then why not link Table4 to Table2?

    If you want to duplicate Table2 to Table5, then my question still holds how will you do it? Through a button? and on which table?

    I'm heading out for a few hours. If no one else responds I'll see where you are at when I get back.

    • Fred
    • 4 mths ago
    • Reported - view
     said:
    let d := format(Date, "DD.MM.YY"); (select 'Table2')[format(Date, "DD.MM.YY") = d].number
    if ш use this formula, having previously created the 'Date' fields, then in the field it takes data from all the fields from table 2, there are three records. How to make it so that all the records from table 2 are created separately in table 5? I need to solve this issue

    When you are trying to find a set of records that you need to then do something with each record individually, then you need to:

    1. create an array of the record Ids
    2. use the for loop

    So to do step 1, you could do something like:

    let d := Date;
    let recsToDuplicate := (select 'Table2' where Date = d)

    You don't need to format the Date field since you are not displaying it.

    In line 2, I put the results of the select into a variable and I removed the square brackets [ ]. Why, because when you use a square bracket in a select you are telling Ninox to send over the entire table to your computer and then your computer will filter the results. Not something you want to do if your table has 1,000 or 10s of thousands of records. Always start with the where, but there could be moments where you need square brackets with a select statements.

    Now that we have an array, in the variable recsToDuplicate, to work with we can add a for loop to cycle through the array and do something with each record.

    let d := Date;
    let recsToDuplicate := (select 'Table2' where Date = d);
    for record in recsToDuplicate do
        let newRec := create Table5;
        newRec.(
            'Tab. Name' := record.'Tab. Name';
            Number := record.Number;
            Group := record.Group
        )
    end

    But there is a link that is not created, the link between Table4 and Table5. Why don't you give it a try on how to create that link. You will need to:

    1. find the appropriate record in Table4 and put it in a variable
    2. modify the newRec.() part of the code to use the variable from step 1 to make the link
    3. you will need the first() command as well
    • Fred
    • 4 mths ago
    • Reported - view

    Are GM TABLE records differentiated by Date? So there is only 1 record in GM TABLE for each day?

    Your Daily Estimation table seems a bit redundant if your GM TABLE is also daily. This could make your Hourly Estimation table a sub table of GM TABLE. You would have to switch the reference direction. You have the reference (1:N) from Hourly to GM TABLE which is backwards. It should be many Hourly to one GM. So you would create the reference field in Hourly Estimations to GM TABLE.

    It seems like you would also need number fields to store what you had on hand at that hour instead of formula fields as that would change as your numbers change.

    • Fred
    • 4 mths ago
    • Reported - view

    Take a look at the attached DB.

    It will open to a dashboard. You can play around with the selecting a GM TABLE record then a table record then you can click on Create Hourly Estimate and see that it creates an hourly estimate of the table you selected.

    The other button to create a table doesn't do anything.

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       Hi

      I think you have the right direction for solving the problem. I think that if the Dynamic choice is replaced with a Multi Dynamic choice, this will be the solution to this problem. There remains one task, so that he makes not just one table, we need all the table that will be selected

      • iliper LTD
      • iliper_LTD
      • 4 mths ago
      • Reported - view

       Hi

      I'm trying to change the location of the button and the dynamic selection field. I moved them in the "Hourly Estimation". So, that I don't have to select the day in field 'GM Table' every time, I placed it in the main table, "Daily Estimation" and changed its location in the formula 'Daily Estimation'.'GM TABLE'.Tables. But the dynamic selection field doesn't give an error, but it doesn't work either.

      Please look at the attached DB, and in particular the table "Daily Estimation". I think (and i hope) if you can make the buttons, where they are now, work correctly, that would be the solution.

      Thank you in advance for your support and help

      • Fred
      • 4 mths ago
      • Reported - view

      In your workflow, do you

      1. always create hourly estimates for all tables?
      2. do you want the ability to select the tables you want to create hourly estimates for?

      I moved the Hourly Estimation table to under GM TABLES. Plus the button doesn't link Daily Estimations to GM TABLES so that is why nothing shows up in the dynamic choice field.

      I'll load up your DB setup and write the script based on your setup.

      • Fred
      • 4 mths ago
      • Reported - view

       Do you want Daily Estimations linked to GM TABLES? You have it setup to be N:1 from Daily Estimations to GM TABLES. It would work better if it was switched, unless you plan on having multiple GM TABLES connected to 1 Daily Estimation.

    • iliper LTD
    • iliper_LTD
    • 4 mths ago
    • Reported - view
    • iliper LTD
    • iliper_LTD
    • 4 mths ago
    • Reported - view

Content aside

  • 4 mths agoLast active
  • 18Replies
  • 98Views
  • 2 Following