6 Replies Latest reply on Mar 2, 2013 10:02 PM by geoffeddie

    Need script help

    geoffeddie

      Title

      Need script help

      Post

            

           Hello All!

            

           I have a roll-stock printing database in which I want to create a set of unique records based on a set or "How Many To Create" button which would be how many rolls can be cut from a larger "Parent Roll."

           The reason for the mass replication is to save time when in the production environment, the operator does not have time to create a single Child record from each Parent even with an Auto-Enter present. 

            

           For Example:

           1. Parent Roll can be cut down to 4 Children Rolls so the "4" value would be entered into the "How Many To Create Field"

           2. Information (traceability info, paper lot numbers and such) is entered into the first set row which is then copied down by whatever the value is in the "How Many To Create Field"

           3. The replication is continued until the information is changed in the row.

            

            

           It is troubling me on how to write this script.

           Any help is appreciated.

            

           G

            

            

            

      dashboard.jpg

        • 1. Re: Need script help
          philmodjunk

               I wouldn't set up the tables quite like you have them here.

               

                    Information (traceability info, paper lot numbers and such) is entered into the first set row which is then copied down

               That would seem to produce unecessarily redundant data unless these values can be later modified to be specific to an individual roll. If this data is the same for all rolls cut from the same master, they should only be stored with the record for the master roll. The relationhip back to the record for the master roll will make all such data readily avaialble for each child roll without a need to duplicate teh data into each child roll record.

               Assuming this relationship:

               MasterRolls::__pkMasterRollID = ChildRolls::_fkMasterRollID

               Your script to generate a specified number of records in ChildRolls all linked to the current record in MasterRolls might be this:

          #Make gChildRollQuantity a field with global storage
               #Start script from layout based on MasterRolls table

               Freeze Window
               Set Variable [$MasterRollID ; value: masterRolls::__pkMasterRollID
               Go to Layout [ChildRolls]
               Loop
                  Set Variable [$K ; value: $K + 1]
                  Exit Loop If [$K > Globals::gChildRollQuntity] 
                  New Record/Request
                  Set Field [ChildRolls::_fkMasterRollID ; $MasterRollID ]
               End Loop
               Go To layout [original layout]
                

                

          • 2. Re: Need script help
            geoffeddie

                  

                  

                 Thank you for the help!

                 Would you recommend a Master Roll Table and Child Roll Table to do this or is that neccesary?

            • 3. Re: Need script help
              philmodjunk

                   These could be two occurrences of the same table or two separate tables. I suspect that two separate tables will make the most sense as you will likely store quite a bit more data about the master roll than the child rolls.

                   Whether two separate tables or two occurrences of the same table, you'll need that relationship to link the child rolls--the rolls cat from the master back to the record for the master roll. This provides your tracebility and avoids the need to repeatedly enter the same data when it is common to all child rolls cut from the same master roll.

              • 4. Re: Need script help
                geoffeddie

                     So one last comment...

                     I need to produce a label from each child roll for traceability purposes. As stated, each set is determined by the number across as above.

                     For instance, the first set of how many rolls say 1-3 would be labeled as:

                     M1 R1 would identify the 1st unique roll from Master Roll 1

                     M1 R2 would identify the 2nd unique roll from Master Roll 1

                     M1 R3 would indentify the 3rd unique roll and so on from Master Roll 1

                     Would this still be possible to do using the script above?

                     Thanks

                      

                • 5. Re: Need script help
                  philmodjunk

                       You don't need a script really. In place of M1, refer, to the serial number value for the related MasterRoll Record. If you also have serial number fields in the Child Roll table, these can serve in place of R1.

                       But if you must number the child rolls sequentially 1, 2, 3, then the script can be easily modified to add one more Set Field step:

                  Make gChildRollQuantity a field with global storage
                       #Start script from layout based on MasterRolls table

                       Freeze Window
                       Set Variable [$MasterRollID ; value: masterRolls::__pkMasterRollID
                       Go to Layout [ChildRolls]
                       Loop
                          Set Variable [$K ; value: $K + 1]
                          Exit Loop If [$K > Globals::gChildRollQuntity] 
                          New Record/Request
                          Set Field [ChildRolls::_fkMasterRollID ; $MasterRollID ]
                     Set Field [ChildRolls::CutSequence ; $K ]
                       End Loop
                       Go To layout [original layout]

                  • 6. Re: Need script help
                    geoffeddie

                         I have been having issues trying to set up this script.

                         Is it possible to provide a sample working solution?