1 Reply Latest reply on Mar 8, 2010 5:37 PM by JoshO.

    Script to duplicate current portal row and then set cursor in specific field

    vicioustruth

      Title

      Script to duplicate current portal row and then set cursor in specific field

      Post

      I have 3 tables: SoldJobs, Labor, and Employees.

      These 3 tables are related:

       

      SoldJobs----------->(Allow/Delete)Labor<----------------Employees

       

      On the SoldJobs layout, I have a portal using the SoldJobs_Labor relationship. 

      The portal fields are as follows:

       

      Date - EmployeeID - EmployeeName - HourlyRate - Hours - TotalLaborCost - CostedTo

       

      When the user enters data in this portal, most of the time there will be quite a few rows where only the date and hours data will change. 

       

      I want to create a scripted button that does the following: 

       

      Duplicate highlighted portal row

      In the newly created row, I'd like to delete the data in the Hours field, and then set the cursor so that the user can type in new data into the Hours field. 

       

      Currently, my script looks like this:

      Go To Portal Row [Next] (Select Entire Contents)

      Duplicate Record/Request

       

      When I run the script, it creates a new portal row, but all the fields are blank.... 

       

      Where have I gone astray?

        • 1. Re: Script to duplicate current portal row and then set cursor in specific field
          JoshO.

          The Duplicate Record/Request step works on the current record...which is the record on the table the layout is based.  Portals are windows into another table, showing related records.

           

          In layout mode, give the portal an object name (using the Object Info palette).  For example, "LaborPortal".

          Set the Hours field as a text field with an auto-enter option.  Use "" (that's 2 double quotes) as the text to enter.

           

          You script will do something like this:

           

          1. Use Go to Related Records to go to the record from the Table Occurrence that the portal is based on.
          2. Duplicate the record.
          3. Go back to the original layout.
          4. Use Go to Object to go to the portal.
          You will need some way to get to the desired portal row.  Which will depend a lot on how you have the portal sorted (if at all).
          You could also have the person enter the data in the related record before going back to the original layout...it's up to you.