3 Replies Latest reply on Sep 13, 2010 12:45 PM by philmodjunk

    Problem Adding Contacts

    PCow

      Title

      Problem Adding Contacts

      Post

      I have a sales invoice form with about 1000 of my recent invoices. In order to have the fields auto-enter my contacts information I did the following. 

      I set the company name to Auto-Enter using existing tab from the data section of the field. (Far right side)

      Then I set a calculate formula for the 'Street' 'City' 'State' and 'Zip' by entering in the calculate prompt

      For Street:   Case (Ship To Company::ShipToContacts Company Name; ShipToContacts::'Street')

      For City:   Case (Ship To Company::ShipToContacts Company Name; ShipToContacts::'City')

      For State:   Case (Ship To Company::ShipToContacts Company Name; ShipToContacts::'State')

      etc.....

      The problem that I am having is that if I need to add a new customer then I have to go to the ShipToContacts file and create a new record. I then have to go to to the invoice and fully type in my contacts name (the first time only, remember its set to auto-enter existing information) and then it will show the correlating data. After that I can simply begin to type the company name, select it and viola its done.

      What I need to know is how do I make it where I can add a new company name and insert the data manually 'street' 'city' 'state' etc. and have it save that data to my ShipToContacts database.

      ANY HELP WOULD BE GREATLY APPRECIATED!

      Best

        • 1. Re: Problem Adding Contacts
          philmodjunk

          Define the Street, City, State fields as text fields instead of calculations. Set a looked up value auto-enter field option on each to copy the contact info from the Company table.

          Now you can write a script that takes the new data and enters it into a new record in your contacts table.

          Freeze Window
          Set Variable [$Street ; Value: Invoices::Street ]
          Set Variable [$State ; Value: Invoices::State ]
          Set Variable [$City ; Value: Invoices::City ]
          Set Variable [$CompanyName ; Value: Invoices::CompanyName ]
          Go To Layout ["ShipToContacts" (ShipToContacts)]
          New Record/Request
          Set Field [ShipToContacts::Street ; $Street ]
          Set Field [ShipToContacts::State ; $State ]
          Set Field [ShipToContacts::City ; $City ]
          Set Field [ShipToContacts::CompanyName ; $CompanyName ]
          Set Variable [$CompanyID ; Value : ShipToContacts::CompanyID ]
          Go To Layout [Original Layout]
          Set Field [Invoices::CompanyID ; $CompanyID ]

          I suspect from your description that you've linked your records by Company Name. This can cause problems as company names aren't always unique and are subject to change from time to time. They should be linked by CompanyID instead of the name. You can use a two column value list so you can select a company by name, but enter the ID number. (There are also scripted approaches you can use to find and enter an ID after entering/selecting a company name from an auto-complete dropdown of company names.)

          • 2. Re: Problem Adding Contacts
            PCow

            I really like that script. My invoice page is named 'SalesOrders' so all I should have to change is the;

            Set Variable [$Street ; Value: Invoices::Street ]
            Set Variable [$State ; Value: Invoices::State ]
            Set Variable [$City ; Value: Invoices::City ]
            Set Variable [$CompanyName ; Value: Invoices::CompanyName ]

            to 'SalesOrders' correct?

            Also, where in my scripts for my invoice should I inject that script? Does it really matter? Im not great with FMP by any stretch of the imagination. 

            • 3. Re: Problem Adding Contacts
              philmodjunk

              Yes,

              There are a number of ways to implement the script. The simplest is to just add a button to your SalesOrder layout that performs this script when clicked.