2 Replies Latest reply on Mar 20, 2010 1:48 PM by Sketter

    Script questions



      Script questions


      I have two questions.


      I have never worked with Loops before, but from what I have read, I need a script that goes to every record and perform something.


      Would it be proper to do a loop with if one of my functions being  a "Go To Record/Request step has an “Exit after last”" and I can end the loop with that right? (and I would still need to end the loop with End Loop?)


      Second part, and I beg for your patience with me. (I'm going to try my best to explain this)


      I have a script that the goal is to import data from a spread sheet into a database.

      I have quite a few tables in this database.

      The speed sheet has columns(fiends) that are in different tables.  So to compensate for this, I created a layout and table that will first take all the data from the spread sheet, and then plan on using another script that is commonly used when you create a single entry.

      (In this database, when I add a Person, I created a button that will also create another record on another table, and of course made the records relate to one another(portal))


      At one point (well two) you come across where it's not a text field, but a value list drop down box.

      My first question is, how do I make the script determine based on a text field, what to pick in the value list?

      My second question is, IF it can't find the value it wants, (and this value list drop box is editable) how can I make the script add the value?


      There is one more question, but I want to stop there for now.



      Thanks very much everyone!



        • 1. Re: Script questions

          Every Loop requires an End Loop. (Just as an If requires an End If.) It's extremely important that when you construct a Loop, you provide some kind of exit, else you'll get stuck in an endless cycle.


          Yes, using Go to Record (Next or Previous) with "Exit after last" is one way to exit a loop. Another is the Exit Loop If step, where you provide a calculation or condition that triggers the exit.


          Regarding your imports, I'm not sure if you have a question there or not.


          As for value lists, a script doesn't literally pop up the list and choose something. You just tell it what value you want, e.g.:


          If[ textField = "monkey" ]
            Set Field[ valueListField ; "banana" ]
          End If


          The value will be set regardless of whether it's actually a member of the field's value list. If the value list is based on field data, then the value list itself will now contain the new value.


          There is no way to create or edit custom values via script. (There are workarounds, such as storing your value lists in fields in a single-record table.)


          • 2. Re: Script questions

            So playing around and I was able to get radio buttons to work, as well as value lists.

            Using the Set Field I was able to select the value if the value already existed.  That I can deal with.

            But it seems there is an acceptation.

            If the value list is based off a field, it won't select it. 

            The field will contain the new value, but not select it like it does on custom value list/and radio, even if the value already exists.


            Am I doing something wrong? Or is it not capable of it?

            To me it's important that it selects the pre-existing value, like it does in custom valueslist due to search queries that's done often.




            "There is no way to create or edit custom values via script. (There are workarounds, such as storing your value lists in fields in a single-record table.)"


            Can you explain what you mean by that?

            Is that like taking the data, create a new record in a different table, and create a value list of that field, then go back and have your script set that value to match the one you just put in the other table field?