0

Link tables during import CSV

Does anyone know if this is possible - or do I have to run a script after import ?

I know how to link two tables from button where they both have for example same type of field for a member number , but would be excellent if I could do it via the import to the child.

 

Rgds

Leo

11 replies

null
    • Fred
    • yesterday
    • Reported - view

    I was not able to get Ninox to recognized a number in a CSV to be the record Id of a reference field. It looks like you will need to import the reference record Id into another field then use a button to create the links.

      • Leo_Woer
      • yesterday
      • Reported - view

       Yes I was afraid that this was so - thanks anyway

      • Leo_Woer
      • 21 hrs ago
      • Reported - view

       Hi Fred - hope you can help me here.

      I have the following link script :

      for j in select medlemmer do
          let myText := j.Medlemsnr;
          for i in (select Betalingsliste)[Medlemmsnr = myText] do
              i.(medlemmer := j)
          end
      end

      and it works perfectly, however in the "Betalingsliste" (payment list), there are old members who are not in the present database "medlemmer" (members), and when running the link thes get created in the member database - ho do I avoid this ? My idea was something ala :

      let Xarray := select members.Medlemsnr

      for j in select Xarray do
          let myText := j.Medlemsnr;
          for i in (select Betalingsliste)[Medlemmsnr = myText] do
              i.(medlemmer := j)
          end
      end

      But it seems that it will not recognise the Xarray

      Hope you can help me here

      rgds

      Leo

      • Fred
      • 21 hrs ago
      • Reported - view

      Ninox lets you save the second code?

      In the tables members and Betalingsliste, what kind of field is Medlemsnr?

      • Leo_Woer
      • 21 hrs ago
      • Reported - view

       both are numeric

      • Fred
      • 20 hrs ago
      • Reported - view

       

      let Xarray := select members.Medlemsnr
      for j in select Xarray do
          let myText := j.Medlemsnr;
          for i in (select Betalingsliste)[Medlemmsnr = myText] do
              i.(medlemmer := j)
          end
      end
      

      Then line 3 won't work since the variable Xarray only contains numbers. It is not recordId so you have no where to go.

      You can just modify the code to:

      let Xarray := select members.Medlemsnr
      for j in select Xarray do
          for i in (select Betalingsliste)[Medlemmsnr = j] do
              i.(medlemmer := j)
          end
      end
      

      But I don't think it will make a difference with your problem of records in Betalingsliste with Medlemsnr that do not exist in medlemmer.

      So my question is what do you want to happen with records in Betalingsliste that have no match in medlemmer?

      • Leo_Woer
      • 19 hrs ago
      • Reported - view

      I need them to stay in betalingsliste

      • Fred
      • 19 hrs ago
      • Reported - view

      I'm confused. You are not deleting any records, you are only linking the medlemmer reference field.

      Is there other code you are not showing me that deletes records?

      As of now any Betalinsliste records that don't have a matching medlemmer record will not be linked. Which makes sense.

    • Leo_Woer
    • 18 hrs ago
    • Reported - view

    sorry Fred is occupied the 172 hour then I return

    • Leo_Woer
    • 18 hrs ago
    • Reported - view

    Hi again Fred I am all yours now.

    I did your script (changed members yo medlemmer) - buy iy doesn't do anything.

    To further explain - I only want to link the records from Betalinggsliste for members who are present in medlemmer. The rest of the imported records should only be in the table Betalingsliste for information purpose - these records are members who once were members of this union but we need to store their payment history.

    Hope this gives sense,

    Maybe we could have an if statement in the original link script which sys something ala if the Betalingsliste,Medlemsnr does not exist in meters then skip the linkingscript and go to next record, but how to do that I don't know. I think that you in Ninox can say if exist then link else skip - so maybe this is a way.

    Any suggestions ? 

    • Leo_Woer
    • 17 hrs ago
    • Reported - view

    SOLVED

    I changed the original script to following :

    for j in select medlemmer do
        let myText := j.Medlemsnr;
        for i in (select Betalingsliste where Medlemmsnr = myText) do
            i.(medlemmer := j)
        end
    end

    now I have all the existing records in medlemmer linked to the correct records in Betalingsliste, and all the non existing still resides in Betalingsliste.

    Thanks for you help until now - probably not the last time.

    Have a nice evening 

    Leo