3 Replies Latest reply on Oct 19, 2011 2:49 AM by RalphHahn

    Populate new Estimate with Standard Items based on field value

    FranzLang

      Title

      Populate new Estimate with Standard Items based on field value

      Post

      Hello,

      I am trying to improve a script of mine that populates a new Estimate with a certain number of standard Items.

      My three tables basically look like this:

      Estimates --< LineItems >-- Items

      This is my current script (suggested by Phil almost a year ago, thanks again!)

      -----------------------------------------------------------------

      New Record/Request

      Set variable [ $EstimateID; Value:Estimates::EstimateID ] 

      Freeze Window

      Go To Layout [ “LineItems” ] 

      Set variable [ $int; value:0 ] 

      Loop (Start)

        New Record/Request

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

        Set Field [ LineItems::EstimateID; $EstimateID ] 

        Set Field [ LineItems::ItemID; $int ]

      End Loop If [ $int = 5 ] 

      Go To Layout [ “Estimates"]

      -----------------------------------------------------------------

      I am starting to realise that it would be more flexible to derive the standard items from a field rather than a loop based on the ID.

      So I created a new field standard in my Items table. Each record that contains a 1 here is a standard field and should automatically be included in a new estimate. 

      -----------------------------------------------------------------

      So how can I get my script to create a new Estimate with those standard items?

      I've been trying to do this for about 3 hours today, but no success. Can anybody help?