0

need help on importing a .csv into two related tables (scripting help?)

I have a ninox.com database with two working tables: Contacts (to track association members) and Events (to track events to which those members are invited). The goal is to import members' attendance after each event, via .csv import. Tables Contacts and Events  are correctly linked via a third table called RSVP. I have imported an updated .csv file to a temporary table called StagingImport (a Nioxus video suggested that approach, with a script to update the actual records from here). The first column in the table attached here shows the fields in StagingImports and their field names. The second column shows the fields that need to be updated in the Contacts table and their field names (some are slighly different). The third column shows the fields that need to be updated in Events, and their field names. When I started looking at Ninox's scripting docs I realized I was in over my head. I tried asking ChatGPT (yeah, I know) for a script for a "Process the CSV Import" Button, and needless to say it errors out. The attached doc contains the label info for each table and (on page 2) the script suggested by ChatGPT. I'd appreciate any help you can offer either in correcting the script, or if there's a better (simpler) approach.

62 replies

null
    • szormpas
    • 3 days ago
    • Reported - view

     We made it!

    The issue in your database came up because the 'Event ID' field in the StagingImport table was set to number data type. So, I changed it to a text field type.

    Everything seems to be working as expected now. Are you happy with the final result?

    Today, I learned how to add a newly created record to an array of selected records using code. I have to thank    for his helpful contribution.

    I've attached the updated version of your database.

    Best wishes

      • szormpas
      • 3 days ago
      • Reported - view

        

      Could you please use the updated version of the database I uploaded above? I think it's easier since there's no real data yet.

      • Dave_Airel
      • 3 days ago
      • Reported - view

       Yeah, I agree. But (sorry) I have no idea how to put it back in place. My Starter plan only allows automatic backups so I assume I'll have to go back through the app. If I am able to open it in the app can I then get it back into my online account?

      Im really sorry this has taken up so much time. I had no idea this was going to be this complicated.

      • Dave_Airel
      • 3 days ago
      • Reported - view

       I was able to open your updated file in my app, and just ran the same 4-record import. Looks like it worked (hallelujah!) Now I just need help getting back into my online account ...

      • szormpas
      • 3 days ago
      • Reported - view

        just go to your online account and click on 'import archive'.

      • Dave_Airel
      • 3 days ago
      • Reported - view

       Ok, that worked. THANK YOU. I'm shutting down for today and will do some more exhaustive testing tomorrow. Is it ok if I post again on this thread afterwards if I come up with anything else? Again - thanks to you all for the assist. 

      • szormpas
      • 3 days ago
      • Reported - view

       well done!

      • szormpas
      • 3 days ago
      • Reported - view

        please mark the post as answered.

      • Dave_Airel
      • 3 days ago
      • Reported - view

       done

    • Fred
    • 3 days ago
    • Reported - view

    Love to see the support of the community in support of  doing the main coding.

      • Dave_Airel
      • 2 days ago
      • Reported - view

       Agreed.  saved me countless hours of frustration. Much appreciated!!!

    • Dave_Airel
    • 2 days ago
    • Reported - view

    Hi,  - one more question if you don't mind. Is your script expecting the Attended field in the RSVP table to be a text field or a choice (yes/no) field? It's currently a yes/no field and seems only to be populating Yeses correctly.

    The .csv file is either yes or blank, so I have this 'trigger after update' on the field: 

    if Attended := true then true else false end

      • szormpas
      • 2 days ago
      • Reported - view

        Hi,

      The script expects compatible data types between the 'Attended' fields in the RSVP and StagingImport tables.

Content aside

  • Status Answered
  • 2 days agoLast active
  • 62Replies
  • 88Views
  • 4 Following