7 Replies Latest reply on Jun 26, 2010 10:02 PM by schnook

    Script help needed please

    schnook

      Title

      Script help needed please

      Post

      Hello All,

       

      Don't understand programming so please bear with me.

       

      I am trying to copy and paste data from certain fields in one layout to other fields in a different Layout via a script trigger.

       

      Below is a script that i am trying to get to work, don't know if it's the wright way to do it or not, what it is doing so far is going to the Layout and creating a new record but it is not pasting the data into the fields. Any help would be great.

       

      If [New Radio Log:Overnight = "YES"]  (This where the script is triggered)

      Copy [Select; New Radio Log::Frequency]

      Copy [Select; New Radio Log::From]

      Copy [Select; New Radio Log::Vessel Names]

      Copy [Select; New Radio Log:Persons on Board]

      Copy [Select; New Radio Log::Mobile Phone]

      Copy [Select; New Radio Log:Position]

      Go To Layout ["Overnight Log" (Overnight Log)]

      New Record/Request Paste [Overnight log::Frequency]

      Paste [Overnight log::Vessel Registration]

      Paste [Overnight log::Vessel Name]

      Paste [Overnight log:POB]

      Paste [Overnight log::Mobile Phone]

      Paste [Overnight log:Position]

      End If

       

      Regards

      schnook .

        • 1. Re: Script help needed please
          ryan

          Try this script:

           

          If [New Radio Log:Overnight = "YES"] ##This is your script trigger, as stated earlier

          Set Variable [$RecordNumber; Value:Get ( RecordNumber )] ##This stores the number of the current record

          Go To Layout ["Overnight Log" (Overnight Log)]

          New Record/Request Paste [Overnight log::Frequency]

          Set Field [Overnight log::Vessel Name ; GetNthRecord ( New Radio Log::Vessel Names ; $RecordNumber )]

          Set Field [Overnight log::POB ; GetNthRecord ( New Radio Log::Persons on Board ; $RecordNumber )]

          Set Field [Overnight log:Mobile Phone ; GetNthRecord ( New Radio Log:Mobile Phone ; $RecordNumber )]

          Set Field [Overnight log::Position ; GetNthRecord ( New Radio Log::Position ; $RecordNumber )]

          End If

           

          Please note:  I did not incorporate REGISTRATION, FREQUENCY, and FROM fields in the New Radio Log table in this script as i did not see the corresponding fields in the Overnight log Table.

           

          But the above should make it clear how you can incorporate those fields as well.

           

           

          • 2. Re: Script help needed please
            comment_1

             


            rdowler wrote:

            Try this script:

             

            If [New Radio Log:Overnight = "YES"] ##This is your script trigger, as stated earlier

            Set Variable [$RecordNumber; Value:Get ( RecordNumber )] ##This stores the number of the current record

            Go To Layout ["Overnight Log" (Overnight Log)]

            New Record/Request Paste [Overnight log::Frequency]

            Set Field [Overnight log::Vessel Name ; GetNthRecord ( New Radio Log::Vessel Names ; $RecordNumber )]

            Set Field [Overnight log::POB ; GetNthRecord ( New Radio Log::Persons on Board ; $RecordNumber )]

            Set Field [Overnight log:Mobile Phone ; GetNthRecord ( New Radio Log:Mobile Phone ; $RecordNumber )]

            Set Field [Overnight log::Position ; GetNthRecord ( New Radio Log::Position ; $RecordNumber )]

            End If


            I don't think this will work, becuase (a) there seems to be no relationship between the tables, and (b) the record's number in the found set is not necessarily the same record's number in a related set.

             

             

             

            @schnook:

             

            You should be using script variables to load the data, and Set Field[] steps to unload them. However, I am not sure why you need to do this at all. If you mark the record as "overnight", it is already overnight - what's the point of duplicating it in another table?


            • 3. Re: Script help needed please
              ryan

              very true indeed.

               

              thanks for bringing those points out comment.

               

               

              How are those tables related schnook?

              • 4. Re: Script help needed please
                schnook

                G'day rdowler,

                 

                I was going to try something this NewRadioLog::From = OvernightLog::VesselRegristration, would this work and make them related.

                 

                From in the RadioLog is the Vessel Rego field and Vessel Registration is the field in the OvernightLog.

                 

                Higher up think it would be easier for the older folks at the base to quickly see and log off the overnight vessels, because at time we may have 100 or so entries in the log for the day.

                 

                Regards

                schnook

                • 5. Re: Script help needed please
                  fitch

                  When you use the Copy command, it overwrites the last item that you copied. So at the end of all those Copy commands in your script, all you have is the contents of the Position field, nothing else.

                   

                  Rather than copy/paste, use Set Variable and Set Field:

                   

                  Set Variable[ $Frequency ; New Radio Log::Frequency ]

                  Set Variable[ $From ; New Radio Log::From ]

                  etc.

                  go to layout ...

                  new record

                  Set Field[ Overnight log::Frequency ; $Frequency ]

                  Set Field[ Overnight log::From ; $From ]

                  etc.

                   

                  Make sense?

                   

                  The variables only exist while the script is running so you don't have to worry about cleaning them up or leaving confidential data on your clipboard.

                  • 6. Re: Script help needed please
                    LaRetta_1

                    We discussed this here.  There is no need to copy all the information again to another table.

                    • 7. Re: Script help needed please
                      schnook

                      Hello Fitch

                       

                      Thanks for putting in dummy terms for me just the way i needed it to be shown. It works a treat.

                       

                      Also big thanks to everyone who posted to my problem.

                       

                      Regards

                      schnook