5 Replies Latest reply on Jul 26, 2013 4:11 PM by philmodjunk

    Use one button to auto-fill three fields from previous record

    HenryMeadors

      Title

      Use one button to auto-fill three fields from previous record

      Post

           I know that I can easily set up a button to auto-fill a single field with data copied from the last visited record - I'd like to extend that to auto-fill three fields, though.

           The three fields are for the users to enter the date they collected their data. Because of how our data is formatted and stored, it needs to be broken up into three separate YYYY, MM, DD fields, so using the auto-date thingy isn't really practical (that, and the date they gathered the data may not be the date they're entering it onto the form).

           Large swaths of the data they enter are going to belong to the same date group, though, so I thought it might be helpful for them to be able to just tap one button on the iPad to auto-fill the same date as the last record, until they need to make a date change for whatever reason.

            

           So, lengthy and probably unnecessary description aside, how would I make one button fill out three fields with the values from the last record?

        • 1. Re: Use one button to auto-fill three fields from previous record
          philmodjunk

               That depends on your definition of "last record". A script can have three set field steps as easily as it can have one so tapping a button that runs a script to enter the data should be quite simple to set up.

          • 2. Re: Use one button to auto-fill three fields from previous record
            HenryMeadors

                 "Last Record" being the record immediately before the one you're currently on. I know the default Last Record thing goes off of the last record you viewed, which isn't necessarily the record before the one you're working on.

                 So, I need to figure out how to do a script that says "When I click this button, fill out the fields YEAR, MONTH and DAY with the same values from the record before this one".

                  

                 edit: Assume I'm a total newbie at this program and don't know all the easy and/or correct ways to do this stuff (because I am and I don't ;) )

                 edit2: I figured it out. Using the script manager, I made a new script with multiple Set Field lines for YEAR, MONTH and DAY which each used the function GetNthRecord(FORM::FIELD;Get(RecordNumber)-1)

                 This seems to work for my purposes, unless you know of a better way to do it

            • 3. Re: Use one button to auto-fill three fields from previous record
              ninja

                   Please be firmly aware that the "record before this one" is dependent on your sort order...if you sort differently, you may get some odd and undesired results.

              • 4. Re: Use one button to auto-fill three fields from previous record
                HenryMeadors

                     That's a good note to keep in mind. Ideally, my users shouldn't be sorting the data themselves anyway - they should just be entering the number of whatever species of grasshopper they find, and then move on to the next record. I will be left to do all the major sorting, formatting and exporting of this data into CSVs which we host on our server once they've completed their data entry. 

                     I suppose that raises a good point, though - how can I keep my users from messing with how the data is sorted? Ideally, it'll stay sorted by the order in which they entered each record. The crux, though, will be that I still want them to have the ability to go back and forth between the records, modify the records in case they made a mistake, or delete a record entirely if it's necessary.

                • 5. Re: Use one button to auto-fill three fields from previous record
                  philmodjunk

                       Since your records are in a portal, the order of the records in the portal is fixed unless you go to considerable lengths to provide an option for changing that order in the portal. So Ninja's concern isn't a major issue in this context.

                       I'd take a nother look at your three fields for three parts of the same date. Given how the iOS date picker works, you might find it works pretty well to just enter a single date and then, if you need the separate fields, use calculations to extract the needed month, day and year values. That allows you to take advantage of the built in date validations to keep users from entering  an invalid date such as Feb 30 or some such...