2 Replies Latest reply on Sep 29, 2010 3:06 AM by LaRetta_1

    New Sequential Portal Record



      New Sequential Portal Record


      I'm trying to script a button that will add a new portal record, using another portal record's information. In this example, the portal shows each budget year:

      Budget Year 1 Start & End: 2008-2009

      Budget Year 2 Start & End: 2009-2010


      I want it to take the latest budget year's (in the example above Budget Year 2) info and use any of its field values as defaults for the new portal record. The script I have now works but involves looping. I was wondering if there is a more efficient method?

      This is essentially what I currently have


      Set Variable [$MaxBudgetStart]; Value:Timestamp ( Date(1;1;1950); Time(0;0;0) )] //default max date

      Go to Object [Object Name: "myPortal"]


      Go to Portal Row [Select; Next]

      If [table::budgetStartDate > $MaxBudgetStart]

      //update $MaxBudgetStart

      //keep track of portal row number in $LatestBudgetYearRow

      End If

      Exit Loop If [IsEmpty (table::budgetStartDate)]

      End Loop

      If [not isEmpty($LatestBudgetYearRow)]

      Go to Portal Row [No dialog; $LatestBudgetYearRow]

      //store field values in local variables

      Go to Portal Row [Select; Last] //new portal row record

      //set field values using local variables


      Go to Portal Row [Select; Last]

      End If



        • 1. Re: New Sequential Portal Record

          If you can find a way to sort these portal records in descending order, you can specifiy this sort order in a relationship (use a different table occurrence to the same table than what you used for your portal if you don't want the portal sorted the same way) and then a single set field or set variable script step or even a calculation or Looked up value setting can access a field from the most recent budget year record.

          Set Variable [$MaxBudgetStart]; Value: MaxBudgetYear::BudgetYearStart ]

          Just specify a sort order by BudgetYearStart in descending order in the relationship to MaxBudgetYear.

          If "table occurrence" is a new term, see this thread:  Tutorial: What are Table Occurrences?

          • 2. Re: New Sequential Portal Record

            This table which holds the budget years should be handled without script.  Consider this:

            Add to this budget table a number field called Serial which is the start year (auto-enter serial starting at 2008 for instance).  Then you simply have a calculation called cBudgetYear with:  Serial & "-" & Serial + 1

            To start this process, show all records and place your cursor in the serial field and Replace Field Contents with 'by calculation of':

            Left ( budgetyear ; 4 )

            Once this is correct, you can change your BudgetYear to a calculation (text) with the Serial & "-" & Serial + 1 calc.  Then set your next serial (in auto-enter) to the next year, such as 2011 and you'll be in business - never having to worry about it.