5 Replies Latest reply on Feb 1, 2011 2:24 PM by philmodjunk

    create new contact record - script



      create new contact record - script


      i'm using FM 11 and the Lending Library starter template. i'm pretty much a beginner here. thanks.

      To "check-out" an asset, the user clicks on a button on the asset record page that starts a sequence of "check-out" scripts:

      - go to list layout of Contacts Table showing existing contacts. user selects their name from the list and

      - goes to layout in History Table that asks user to fill in due date for item and click "continue" button

      - window returns to asset record page, item status is now "not available"

      Primary question:

      1.) how can i give the user an opportunity, during this process, to add a new contact record for themselves (if they're not already in the system)?

      Secondary question:

      2.) how can i make this whole sequence be carried out in a pop-up window that closes when the whole sequence is processed? user should see asset window they saw last before check-out sequence


        • 1. Re: create new contact record - script

          Since your script pauses on a contact list layout basd on contacts. You should be able to add a button there that uses New Record to create a new contact record. Since contact list probably does not display all the fields need nor is it likely set up to allow editing, such a new contact button could switch to the correct layout, create a new record and pause for the user to complete the new contact record. Continuing the script can continue your check out process.

          To make this more flexible, I'd have the original script take the user to contact list and then stop instead of pausing. The buttons on contact list that continue the paused scripts can be update to run a new script that continues the check out process. That way, clicking a contact name still selects it and completes the check out, but clicking "new contact" can create a new contact record and then use it to complete the check out process.

          Once you have all that working you can try using the New Window script step to open a new window right at the start of "process check out". Make the last step of the last script a step that closes this same window to dismiss it.

          • 2. Re: create new contact record - script

            great, thank you. i used the second method, and it seems to work, with one glitch.

            i revised the original script ("Process Check Out - Contacts") so it looks like this now:

            Allow User Abort [Off]

            Show All Records

            Go to Layout ["Contact Select List" (Contacts)]

            Sort Records (Restore; No dialog}

            Go to Record/Request/Page [First]

            Show/Hide Status Area [Lock, Hide]

            Adjust Window [Resize to Fit]

            Halt Script

            I created a new script called "Continue Check Out" and I assigned it to the blue arrow next to each name in the Contact Select List. 

            the "Continue Check Out" script is just this:

            Set Field [Contacts::Global Contact ID; Contacts::Contact ID]

            Perform Script ("Process Check Out - History") 

            I created a new layout for users to create a new contact record, a button at the top of the Contact Select List takes them to the new record layout. At the bottom of the New Contact Record layout, I have a button that says "Continue", that takes user back to Contact Select List layout:

            Go to Layout ["Contact Select List" (Contacts)]

            when back at the Contact Selection List layout, users who created a new contact record see their new name in the list and they can click on the blue arrow, and follow the "Continue Check Out" script.

            the only problem now is, the "items on loan" list shows previous borrowers for a certain item, rather than those that i had "create new contact" during the check-out process. i imagine the assigning of a global ID to the asset or contact may have gotten screwed up somewhere?

            • 3. Re: create new contact record - script

              When I opened a copy of this solution and checked the relationship involved, I didn't see any global fields that would explain this. The names and dates listed are based on this relationship:

              Assets::AssetID = History Asset ID::AssetID   (History Asset ID is a table occurrence of History)

              I haven't examined the script that is used to return items, but I assume that it must in some way alter the value stored in History::AssetID to break this connection or this report will always list the first such person that checked out that asset.

              • 4. Re: create new contact record - script

                disregard my issue mentioned above. all is well! i found this was a glitch with this particular template, and followed instructions on Knowledge Base Article #543, here:  http://help.filemaker.com/app/answers/detail/a_id/543/kw/lending%20library

                separately, though, given my success, i'd like to customize what i've got a slight bit more:

                - how might i go about making an "automatic due date" instead of having the user type in their own due date? i'd like to have an automatic due date of 30 days after check-out date, and send an email reminder 30 days after check-out date as well.

                - time of check out or check in is no longer neccessary — how can i just delete this element from the template?


                • 5. Re: create new contact record - script

                  Dates in FileMaker are really numbers with special formatting. Your script can use set field to enter a date in a field 30 days in the future like this:

                  Set Field [YourTable::YourDateField ; Get (CurrentDate ) + 30]

                  To send out your email reminder, you'd write a script that runs every time you open the file that performs a find for these records. If any records are found, you'd send an email to the contact's email. You'd need to log the fact that an email was sent. Otherwise, if you open the file more than once (or different users open the file on the network) on the same day, your system will send multiple emails out.

                  To remove Time out and Time In, you can simply open Manage | Database | Fields and try deleting them. The system will tell you if these fields are used in other calculation fields, in  a relationship etc. So these messages can help you figure out where else you need to fix references to these fields to eliminate errors. If you have a copy of FileMaker advanced, this becomes much simpler as you can generate a database design report and search it for instances of these two field names to track down all references to them in calculations, scripts, layouts, etc.