5 Replies Latest reply on Nov 6, 2009 2:34 PM by philmodjunk

    Need help creating a new record and carrying over two fields

    trialuser1111

      Title

      Need help creating a new record and carrying over two fields

      Post

      Let me see if I can explain this succinctly: We track client meetings by contact, which aggregates to track client meetings by the firms that these contacts work for.  The "Firm Data" table is related to "Meeting History" and "Contacts" via CompanyID.  I've successfully set up the layouts and scripts to have a pop-up window for people to enter a new meeting for a firm (they enter the contact name and meeting details), but I would like to set up a similar window for people to enter meetings for a contact (where the name is already filled in and they just need to enter the meeting details) and I can't figure out how to carry forward the two fields (CompanyID and Contact Name).

       

      Here are the steps for the Add New Meeting (Firm Version) script:

      Commit Records

      Copy [Select ; Firm Data::CompanyID]

      New Window ["Add New Meeting"]

      Go to Layout ['Add Meeting" (Meeting History)]

      New Record

      Paste [Select ; Meeting History::CompanyID]

      Go to Field [Meeting History::Name]

       

      I don't have the scripting skills to tell FileMaker to reference the fields in the background window, or to copy and paste two fields at once.

       

      FYI, the above script is triggered by a button on my Firm Data layout, and I would like to get the Add New Meeting (Contact Version) script be based off the Contact Profile layout.

        • 1. Re: Need help creating a new record and carrying over two fields
          philmodjunk
            

          First, Get rid of the Copy and paste steps. Use Set Field instead.

           

          Now modify your script as:

          Commit Records

          Set Variable [$CompID ; Firm Data::CompanyID]

          Set Variable [$2ndField ; Firm Data::2ndField]

          New Window ["Add New Meeting"]

          Go to Layout ['Add Meeting" (Meeting History)]

          New Record

          Set Field [Meeting History::CompanyID; $CompID]

          Set Field [Firm Data::2ndField; $2ndField]

          Go to Field [Meeting History::Name]

           

          Edit Note: Script corrected to fix error mentioned in following post.

          • 2. Re: Need help creating a new record and carrying over two fields
            trialuser1111
              

            Works like a charm.  I had to tweak the bottom of the formula such that Set Field [Meeting History::CompanyID ; $CompID] but this is terrific.  Now that I understand how Set Variable works, I'm going to use this in a lot more scripts.

             

            This forum never disappoints.

            • 3. Re: Need help creating a new record and carrying over two fields
              allenk
                

              I feel like I'm doing the exact thing as stated in this thread, but my field is not being populated with my global variable as expected.  I have a presentation table with a unique ID field (PresentID) that links to a grant table which includes PresentID and GrantID...one presentation can be associated with multiple grants.  I pass the variable PresentID into my PresentationGrants table layout using the following script...(triggered by clicking on a button)

               

              Set Variable [$PresentID; Value:Presentations::PresentID]

              Go to Layout ["PresentationGrants" (PresentationGrants)]

              New Record / Request

              Set Field [PresentationGrants::PresentID[$PresentID]]

               

              I know my variable is capturing PresentID OK because I added a Show Custom Dialog script which showed the proper PresentID.  The only difference I can see between what I'm doing and the example in this post is a slightly different syntax with Set Field...my variable is in brackets whereas the example below uses ; which may be a difference in FileMaker versions...I'm using version 10.

               

              In any event, the new record command is successful but my PresentID field remains blank.  I've tried Replace Field Contents, but that updates the field in every record, not just the new record.  I've also tried Go to Field thinking it needed to set focus to the field to set the field value...no luck.  Any clue what I'm doing wrong...this is driving me nuts!!

              • 4. Re: Need help creating a new record and carrying over two fields
                allenk
                  

                Ok, so the smiley faces are really : next to the letter P

                haha...that's annoying

                • 5. Re: Need help creating a new record and carrying over two fields
                  philmodjunk
                    

                  To get rid of the emoticons, put a space after the colon. You can edit a post after the fact by selecting "Edit" from the options menu just above the Kudo control on the right.

                   

                  Your last script step should look like this:

                   

                  Set Field [PresentationGrants:: PresentID; $PresentID]

                   

                  [$PresentID]] shows you've put this variable in the repeitition box when specifying the target field, PresentationGrants:: PresentID.

                   

                  Set this back to 1 and click the lower specify... (calculated result) button and enter your variable's name there