3 Replies Latest reply on Aug 29, 2011 9:29 AM by philmodjunk

    Navigate by script to Portal in tab

    PeterDowns

      Title

      Navigate by script to Portal in tab

      Post

      Hi 

      thanks for all your advice in previous postings it has been tremendous.

      I have a parent layout "Record Detail - Projects" with a series of tabs containing portals. This is all good. What I am trying to achieve is on tab1 -  portal 1 I have projected costings for future activities. On tab 2 - portal 2 as the activites occur they type in their actual costings. So to promote laziness and avoid user frustration I have set up a script that copies a record from the projected costings and puts it into the actual costings records. This script is activated by a button from a record in portal 1.

      I have tried it 2 ways - 

      First

      I did a Copy Record/Request and then set the fields with all the values.

      Copy Record / Request
      Set Field [Project_RelatedTasks::Name_Task; ProjectedCosts::Name_Task] 
      Set Field [Project_RelatedTasks::Qty; ProjectedCosts::Q] 
      Set Field [Project_RelatedTasks::Task_Cost; ProjectedCosts::ItemCost] 
      Set Field [Project_RelatedTasks::Description; ProjectedCosts::Description]  
      Commit Records / Requests [Skip Data entry validation] 

      This worked perfectly except it copied the values over the first existing record in the actuals list in portal 2, rather than in a new record.

      2nd way

      I used this Script:
      Set Variable [$TaskName; Value:ProjectedCosts::Name_task]
      Set Variable [$Q; Value:ProjectedCosts::Qty]
      Set Variable [$Cost; Value:ProjectedCosts::ItemCost]
      Set Variable [$Descript; Value:ProjectedCosts::Description]
      Go To Layout ["Record Detail - Projects"(Projects)]
      Go to Field [Project_RelatedTasks::Name_Task]
      Go to Portal Row [Select; Last]

      New Record / Request
      Set Field [Project_RelatedTasks::Name_Task;$TaskName]
      Set Field [Project_RelatedTasks::Qty;$Q]
      Set Field [Project_RelatedTasks::Task_Cost;$Cost]
      Set Field [Project_RelatedTasks::Description;$Descript] 
      Go to Portal Row [Select; Last] 

      This worked well and put it in portal 2 but created a whole new project record rather than in the existing portal record.

      Because both portals are on different tabs they are still both on the same layout - "Record Detail - Projects"
      So I need some help in placing the data into a new record in portal2 in the existing project. Any ideas??

      Cheers

      Peter

       

        • 1. Re: Navigate by script to Portal in tab
          philmodjunk

          Note: Copy Record/Request in your first script does nothing in that script except copy a tab separated set of data from your current layout's current record to the clip board--wiping out anything your user may have previously copied to that clipboard. The set field steps that come after do not reference that copied data at all.

          Your second script will work if you delete the new record/request step. As you have seen, this step creates a new record in the current layout's table, not the portal's. Since you have "Allow creation of records via this relationship" enabled for your portal's relationship, going to the last portal row and entering data creates the new portal record automatically.

          Given potential problems with go to portal row (Note that you can't specify which portal you are interacting with--thus needing the go to field step), I suggest this modification of that script:

          Freeze Window
          Set Variable [$TaskName; Value:ProjectedCosts::Name_task]
          Set Variable [$Q; Value:ProjectedCosts::Qty]
          Set Variable [$Cost; Value:ProjectedCosts::ItemCost]
          Set Variable [$Descript; Value:ProjectedCosts::Description]
          Set Variable [$ProjectID ; value: ProjectedCosts::ProjectID]
          Go To Layout ["Project_RelatedTasks"(Project_RelatedTasks)]
          New Record / Request
          Set Field [Project_RelatedTasks::Name_Task;$TaskName]
          Set Field [Project_RelatedTasks::Qty;$Q]
          Set Field [Project_RelatedTasks::Task_Cost;$Cost]
          Set Field [Project_RelatedTasks::Description;$Descript] 
          Set Field [Project_RelatedTasks::ProjectID ; $ProjectID ]
          Go To layout [original layout]

          Note: I am assuming that ProjectID is the link to the primary key field in Projects on which your portal to Project_RelatedTasks is based. You may need to change those references to make this work with the actual fields in your system.

          • 2. Re: Navigate by script to Portal in tab
            PeterDowns

            Hi

            thanks for that I tweaked option 2 

            got rid of add new record. Went to a field on the portal layout. Then went to last row in that portal, set the fields and it worked a treat.

            Thanks for your help.

            Cheers

            Peter

            • 3. Re: Navigate by script to Portal in tab
              philmodjunk

              Your script will work, I prefer not to interact with portal objects if there is a reasonable alternative. The problem with interacting with a portal row in a script is that future changes to the layout can break the script where switching layouts and using a layout based on the portal's table to create the new records will not be quite as vulnerable.