2 Replies Latest reply on Aug 15, 2013 12:29 PM by JasonvD

    Problem with 2 portals

    JasonvD

      Title

      Problem with 2 portals

      Post

           Hello, 

           I need your help on a quite strange problem with 2 portals in one layout.

           I have a layout named "Inventory" , in which there are 2 protals: "Item"  and "SelectedItemPrice" (a duplicated occurrence of "Price").

           the portal "Item" stores the items in inventory. the portal "SelectedItemPrice" gives different prices for selected item. The relationship and layout attached.

           I have 2 items, Item1 (price 11 and 12) and Item 2 (price 21 and 22).

           In the portal "Item", there is a button that select the item and check the prices in the portal "SelectedItemPrice" (Script: Set Field[Inventory::SelectedItem; Item::ID], Commit Records/requests [No dialog]).

           This part works fine. No problem. The problem comes from the 2nd portal,  "SelectedItemPrice".

           in this protal, there is also a button, which is supposed to pass the price to the selected item. 

           script: Set Field [Item::Price; SelectedItemPrice::Price]     Commit Records/requests [No dialog]

           Here comes the problem. This button indeed passes the price. HOWEVER, it always passes the price to the first item, regardless which Item is selected.

           You can see from the attached screen shot, the price 21 (price for Item2) is set on Item1, while Item2 is selected (highlighted item ID )

           What happened? 

            

      Screen_Shot_2013-08-15_at_12.51.42_AM.png

        • 1. Re: Problem with 2 portals
          philmodjunk

               What happened is that any reference to Item from the SelectedITemPrice portal row goes through inventory to the the related records in item. There is no method being used to select a a particular related item and, by default, the first related item--the first record in your unsorted, unfiltered portal, is the item that is set with the price from selected Item.

               If the button in the item portal set a variable to the current portal row number, that value could be used to re-select the correct portal row after clicking a button in the selectedItemPrice portal:

               Set Variable[$$Row ; value: Get ( ActivePortalRowNumber ) ]
               Set Field[Inventory::SelectedItem; Item::ID]

               Then the button in the SelectedItemPrice portal could perform this script:
               Set Variable [$Price ; value: SelectedItemPrice::Price ]
               Go to Object ["ItemPortalObjectNameGoesHere"]
               Go to Portal Row [$$Row]
               Set Field [Item::Price; $Price ]

               You'll need to use the Name box in the Inspector's position tab to give the item portal an object name for this to work.

          • 2. Re: Problem with 2 portals
            JasonvD

                 It works. Thank you very much, PhilModJunk.smiley