0

Array to records in a table

I have this array:

[{\"Selecciona tu piso\":\"GR. XALET 121\",\"Quan\":\"11-11-2022\",\"Hora\":\"15:15\"},{\"Selecciona tu piso\":\"ST AV FENER\",\"Quan\":\"15-11-2022\",\"Hora\":\"20:40\"}]

 

Also, I have a table with fields:
- place
- date
- time

 

I need to push a button and create a record in the table for each record of the array, putting on each field as follows:

 

record 1:
- place: GR. XALET 121
- date: 11-11-2022
- time: 15:15

 

record 2:
- place: ST AV FENER
- date: 15-11-2022
- time: 20:40

 

Everything that comes before and after the values to extract, are always the same.

 

How would you do that script in the button? 🥺🙏🏼

2 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    Is there anyway to remove the "\"? When I try copying the bit of data Ninox gets all confused with the "\". There is no way that I can see, but I'm not the smartest, that you can use the sample data without Ninox freaking out. I can't use the replace function because you can't use the data as is. You can't put the data into a variable.

    Once you clean it up you can do a lot of things with it. For example:

    let array1 := [{
                'Selecciona tu piso': "GR. XALET 121",
                Quan: "11-11-2022",
                Hora: "15:15"
            }, {
                'Selecciona tu piso': "ST AV FENER",
                Quan: "15-11-2022",
                Hora: "20:40"
            }];
    for loop1 in array1 do
        loop1.Quan
    end
    

    This gets all of the data in from the Quan part of the array.

    ["11-11-2022","15-11-2022"]

      • Ninox developper
      • Jacques_TUR
      • 2 yrs ago
      • Reported - view

      Fred In JavaScript, \ is an escape character that indicates that the next character is not a marker and should be inserted into the string and not interpreted. For example, in a string whose start and end markers are quotation marks and in which you want to insert a quotation mark, you can write it as follows: "\"". The content of this string will be: ". To do the same thing in Ninox, we will double the quotation mark and write: """". 

      I think the SoluMaker array must come from a JavaScript string (or an equivalent). To switch from this format to the Ninox one, you just have to replace \" by " : 

      And so the code that SoluMaker needs a bit like you started to write: 

      let array1 := [{
                  'Selecciona tu piso': "GR. XALET 121",
                  Quan: "11-11-2022",
                  Hora: "15:15"
              }, {
                  'Selecciona tu piso': "ST AV FENER",
                  Quan: "15-11-2022",
                  Hora: "20:40"
              }];
      for i in array1 do
          var rec := create YOU_TABLE_NAME;
          rec.place := i.'Selecciona tu piso';
          rec.date := i.Quan;
          rec.time := i.hora;
      end