1 2 Previous Next 20 Replies Latest reply on Feb 22, 2012 4:00 PM by TraceyLillis

    Custom dialog entry, looping, and automatic data entry

    TraceyLillis

      Title

      Custom dialog entry, looping, and automatic data entry

      Post

      Hello,

      I am trying to work out how to ask users some information using a custom dialog, and then enter this information in a set of found records via looping the script. 

      Currently I have worked out how to manually enter the text into the found records

      • Go to record [first]
      • Loop
        • set field [field name#1]
        • insert text []
        • set field [field name#2]
        • insert text []
        • Go to record [next, exit after last]
      • Exit loop

      Works great, but I want to get fancier and ask the user via a dialog box and then get FM to automatically place this in a set of found records.  When I try, it keeps asking for the user to enter the dialog in each time!  Frown  Obviously I am missing something important in my scripting steps. 

      Any suggestions please?

      TIA

      Tracey

       

       

        • 1. Re: Custom dialog entry, looping, and automatic data entry
          DavidJondreau

          On each loop is field #1 getting the same data put in? And is field #2 getting the same data on each run through the loop? The basic way to do this is to define two new Text fields and set their storage to global. Then have a Show Custom Dialog[] script step before the Loop[] starts. That Custom Dialog should have input fields showing the two new fields. Then in your Loop, instead of Insert Text, use Set Field[] and set the field to the respective (#1 #2) global field.

           

          In short, users will put in their data into the global fields and you'll transfer that data into the individual fields.

          • 2. Re: Custom dialog entry, looping, and automatic data entry
            philmodjunk

            You can also use replace field contents to update the found set in one step for each field instead of using a loop. This is a tool that can change values in 1000's of records and can't be undone so read up on it in help first, then make sure to create a back up copy before you first try this out.

            • 3. Re: Custom dialog entry, looping, and automatic data entry
              TraceyLillis

              Dear David and Phil,

              Thanks for your help.

              I played around with the custom dialog and it is still not working.  It is putting in blank information (even though I have set the global fields) and looping forever, even though I have found a set of records first (only 37 at the present time).  I did forget to mention that the script calls another script which is required (?) to enter a note in the table.  I have modified FM Starting Point database. 

              I have attached a copy of the current script which is not working. 

              Thanks

              Tracey

              • 4. Re: Custom dialog entry, looping, and automatic data entry
                DavidJondreau

                1) It looks like you're setting the global field to itself in the loop and not another field.

                2) What does the "0707" script do? That's probably why the loop isn't exiting.

                • 5. Re: Custom dialog entry, looping, and automatic data entry
                  TraceyLillis

                  Hi David,

                  Sorry for the delay in replying, I was on two weeks leave.  :)

                  In response to your question, the 0707 script is called as it allows a note (record) to be added to the communiation and notes table.  When I have tested the script without the looping, this 0707 script doesn't cause any problems. 

                  Just to let you know again, I am modifying the FM Starting Point database. 

                  Regards

                  Tracey

                  • 6. Re: Custom dialog entry, looping, and automatic data entry
                    philmodjunk

                    As David pointed out, you are setting a field to the value it already contains. This does not result in any data in your database being changed by that script step.

                    Looks like the set field steps should read something like this:

                    Set Field [NotesTable::Note Type ; NotesTable::gNote Type]

                    I'm using the place holder "NotesTable" in place of the sophisticated table occurrence name you have to save typing. Note how the field names are different on each side of the semi-colon, however, that's the issue David is pointing out as a problem here.

                    Here's another issue to look at in addition to that detail:

                    Often, such an "add a note" script changes layouts to a layout based on another table in order to create a new record in that table. If so, it looks like you need to add a go to layout step to return to your original layout just before you use Go To Record [next.... to move to the next record.

                    • 7. Re: Custom dialog entry, looping, and automatic data entry
                      TraceyLillis

                      Thanks for your replies David and Phil.

                      I have spent quite a bit of time playing around with these scripts with no success.  I did do the suggested steps as suggested above and now it seems to be going to each record, but not entering the global text fields. 

                      Here is a copy of the script for the automatic emails and also the script to enter a note. 

                      • 9. Re: Custom dialog entry, looping, and automatic data entry
                        philmodjunk

                        You can remove the go to layout step inside the loop, it doesn't do anything.

                        At the time you run this script, what layout are you on? Does it list TO5c_contacts_Notes||id_contact|?

                        Or is this the occurrence name of a portal on this layout?

                        • 10. Re: Custom dialog entry, looping, and automatic data entry
                          TraceyLillis

                          I am on the Contacts layout (based on TO5_Contacts), which has a portal containing information from the Notes (TO4_Notes) table. 

                          Is this why it is having problems because of the portal?

                          Thanks

                          Tracey

                          • 11. Re: Custom dialog entry, looping, and automatic data entry
                            TraceyLillis

                            Sorry, just re-read you question.  Yes, the portal name is TO5c_contacts_Notes||id_contact|.

                            • 12. Re: Custom dialog entry, looping, and automatic data entry
                              philmodjunk

                              Thus you would have this relationship (just to confirm):

                              TO5_contacts---------------<TO5c_contacts_Notes||id_contact|
                              (Layout)                               (Portal)

                              presumably TO4_Notes and TO5c_contacts_Notes||id_contact| have the same data source table.

                              If you just run Add a Note all by itself. What changes do you see in the portal to TO5c_contacts_Notes||id_contact|?

                              Does the new record appear at the top of the portal or the bottom?

                              Repeat this several times if your portal is currently empty.

                              If you put the global fields directly on the TO5_contacts layout so you can see their values, do you see the values you entered in the global field?

                              • 13. Re: Custom dialog entry, looping, and automatic data entry
                                TraceyLillis

                                I checked the relationship and there wasn't a <TO5c_contacts_Notes|id_contact| relationship.  So I have allowed the creation of records in both TO5_Contacts and the TO5c_contacts_Notes||id_contact|. 

                                When the Add a Note script is run by itself, it adds the record to the top of the portal.  When I checked the setup of the portal, it sorts the records by date and time. 

                                When I add a global field directly onto the T05_contacts layout, it appears. 

                                When I run the script now I have changed the relationship, it is filling in the global fields but only filling in for one student.  Another weird thing is that it puts in 13 blank records and then fills in a record with the global fields and keeps looping.  I have to go into the scipt debugger and halt the script otherwise it keeps making records. 

                                • 14. Re: Custom dialog entry, looping, and automatic data entry
                                  philmodjunk

                                  I checked the relationship and there wasn't a <TO5c_contacts_Notes|id_contact| relationship. 

                                  There has to be a relationship or you don't have a portal, so I do not know what you mean by that.  (in my last post, ---< means "one to many".)

                                  So I have allowed the creation of records in both TO5_Contacts and the TO5c_contacts_Notes||id_contact|.

                                  Not necessary for this script as you are creating new records directly on the table, not via the portal.

                                  When I add a global field directly onto the T05_contacts layout, it appears.

                                  Yes, but you appear to have three global fields populated via input fields on your custom dialog: g_Note_type, g_Note_Subject, g_Note_text. I'm asking you to put them on your layout as a tempory check to be sure they show the values you entered in the input fields of the custom dialog box. Is this the case? Can you confirm in Manage | database | fields that all have global storage specified?

                                  Let's simplify your script while we are at it.

                                  Remove or disable the "go to layout [original layout] step in the add a note script. This way, your loop will assign values from the TO4_Notes layout instead of TO5_Contacts. Modify the three Set field steps inside the loop, to refer to TO4_Notes instead of TO5c_contacts_Notes|id_contact|.

                                  PS. If you have FileMaker Advanced, enable the script debugger and run this script, stepping through the script one line at a time while watching for error codes and checking to see what happens on the screen with each step.

                                  1 2 Previous Next