5 Replies Latest reply on Jun 21, 2017 5:04 AM by alexissindicic

    Import data and create a record in a join table at the same time

    alexissindicic

      Hello Filemaker Community,

       

      I've been on this problem for a while and i have to admit that i am not good enough to resolve it :/

       

      I have three tables :
      - Campaigns

      - Contacts
      - Join_Contact_Campaign

       

      Relationships

       

      • A Campaign can have N Contacts
      • A Contact can be on N Campaigns
      • ... so a Join_table is there to deal with the many to many relationship

       

      Importing contact problem

      Let's say i'm in Campaign ID N°7, i'd like to click on a button (import) and launch a script that will import data from a .CSV file (name / email) into the Contact table. But at the same time i'd like to create this link between contact and campaign using the join table...

      So i need to be able to create a Join_Contact_Campaign record for each of my imported contact.

       

       

       

      Where am i now ?

       

      - I know i can use a $$variable to store the Campaign ID and later use it to populate the Join_Table

      - Someone told me that when you import data from a .csv it creates a "selection" you can play with ; i was wondering if the script should focus on this "selection" and do something like

      for each (record imported)
      create a new record
      take the campaign id and fill this field
      take the contact id and fill this field
      go to next field
      end

       

      But as you can guess, i'm not a programmer

       

      If you have any ideas, feel free to shoot them !