5 Replies Latest reply on Feb 19, 2013 3:28 PM by philmodjunk

    Defining Repeating Field Values



      Defining Repeating Field Values



           I'm mostly done with a task I'm trying to figure out, but hanging up when it comes to repeating fields.  Here's what I'm trying to do:  I'm entering a series of unique key fields manually.  I'd like each one to log in a repeating field, incrementing the repetiion by 1 each time.  At the end I want to display a list of information and "highlight" each line that was entered in the previous step.  If I manually enter the test numbers in the different repetitions of my repeating field, the highlight feature works fine.  What I'm not able to do is store my numbers into the repetitions.

           I tried using variables first, thinking that would be easiest.  That didn't work so I created an actual field for my repeating field, and that didn't work, so I tried making it a global field.  I have the max number of repetitions set to 50 but I don't anticipate ever using more than about 20.  For the repetition number in my script I'm using a variable that increments each time the script runs, so the first repetition would be 1, then 2, then 3, etc.  When you finish, this variable resets to 0.

           As I said before, I think the only issue I'm having is that the numbers I'm inputting aren't storing in the repeating field.  I have a layout where I can see all the repetitions at once and it just stays blank every time I go through the process.  If I manually enter data, it works, but that's not the point...  So to store data in different repetitions I'm currently using:


                Set Variable [$$CO_Mult_Count; Value:$$CO_Mult_Count + 1]


                Insert Calculated Result [Select; Inventory::CTS_CO[$$CO_Mult_Count]; Inventory::kf_CTS_ID]

      •           The variable is the counter for my repetitions, and you can see that it increases by one each time the script would run.
      •           The CTS_CO field is the repeating field that I want the data to be stored in.
      •           The kf_CTS_ID field is the data that I want to store in the repeating field.  Each number I input is in this field at the time this script runs, so it should just pull from the table right into my repeating field (I would think).

           Side Note:  I also tried using a Commit Records command after this...I still haven't been able to tell through trial and error whether or not you need to Commit Records when using a global field, or whether you can just insert the data and it will stay until replaced by something else.  Thoughts?

           Let me know if this needs more clarification.  I tried to explain this complex issue as clearly and thoroughly as possible.  Thanks for any assistance!

        • 1. Re: Defining Repeating Field Values

               I see no reason for you to use a repeating field here. Use a table of related records--one record for each value you are trying to enter. This allows you to enter any number of values that you need to via a portal to the related table and makes for much simpler reporting.

          • 2. Re: Defining Repeating Field Values

                 Ok, but these records are just temporary.  I don't need or want records just accumlating from this process.  Would you recommend that I delete all records in this related table at the end of the process?

                 This is how I understand what you're saying:  I input my key field and it creates a record in a related table.  I continue with the process, then do it again, creating another new record in the related table.  I do this until I have all the items I want.  I then use the related table to run my "highlight" feature, and when it's all done, I delete all those records I just created and start fresh the next time.  Does this sound right?

                 This is basically a logging feature, but I don't need the log once I view the "recap" page.  It can be thrown away and a new log can begin.

            • 3. Re: Defining Repeating Field Values

                   You could definitely delete the related records when you are finished. Though deleting any data, from a repeating field or a related table is not something to do without careful thought as it can't be undone.

              • 4. Re: Defining Repeating Field Values

                     Ok, not to discount your initial advice, but if you would just humor me by answering some of my initial questions about inputing data into a repeating field I would greatly appreciate it.  Even if it doesn't work out for this particular function, these are things I've come across a few times and never quite know the correct way of doing things.

                     To put data into a repeating field does it matter whether you use 'Set Field' or 'Insert Calculated Value', or are they pretty much the same?  And then do you need to 'Commit Record' if it's a global field?  These are my main questions.  Thanks for your help!

                • 5. Re: Defining Repeating Field Values

                       I try to never use the script steps that start with "insert" unless there is a very specific reason for using them. Those steps all silently fail to insert data if the referenced field is not physically present on the layout. Set Field does not have this limitation.

                       Set Field [YourTable::Repeatingfield[3] ; "Apple" ]

                       will put the text "apple" in the third repetition of the repeating field. And you can use a variable in loop to load a series of repetitions with values by putting the $variable name in place of the 3.

                       And you'll find the repetition box at the bottom of the specify field dialog that opens when you click the upper specify button (select target field).