5 Replies Latest reply on Apr 9, 2017 7:22 AM by alisings2u

    go to portal row script step not working


      Hello folks,


      I'm having an issue navigating to the last portal row via a script step.


      I'm doing it by calculation, and though the dialog actually displays the correct portal row (I left dialog on for now, just to be sure), it navigates right back to the first portal row every single time. (screen shot attached)


      What might I be missing? I feel like I'm losing my mind over here! ;-)


      many thanks for any light you can shed,


        • 1. Re: go to portal row script step not working

          And I see more than one portal row in the background.


          Notice that the Go To Portal Row Script step does not have any way to specify which portal has the portal rows that you want to go to. Most likely cause of your issue is that it's going to the portal row of the wrong portal.


          The immediate fix is to give your portal an object name and then write your code as:


          Go to Object [ "Put object name of portal here"]
          Go to Portal Row


          Since go to portal row changes layout focus, it's also possible that the script is tripping a script trigger and performing a script that interferes with the results that you need from your go to portal row script.


          The better fix is to change your approach so that go to portal row is not needed to get the results that you want, if possible. Many scripts that interact with portals can achieve the same results by other methods that avoid tripping script triggers and possibly breaking in the future should an object name be lost during a layout change or due to the future addition of a script trigger to the layout that interferes.

          • 2. Re: go to portal row script step not working

            Hi There,


            I may be way off base here, but I wanted to ask three questions:


            1) is there actually a fourth record? Or will it be created once the user navigates to that row and begins entry?

            2) Are you using go to portal row [by calc]? or directly just saying go to [last]?

            3) Have you tried w/ "select entire contents" set to "off?"

            • 3. Re: go to portal row script step not working

              Hi philmodjunk,


              I did already have the Go To Object step in place everywhere it was needed.


              I've done some fine-tuning to the script since my last post and since reading your comments and those of kazznfx. Now it does reliably navigate to the correct row (though I didn't actually change the parameters of those steps). But in two of the three cases, it does not leave the user in the desired field.


              Some further info, this is an invoicing layout and the section I'm working on invoices for Products.


              After entering the Product ID, the next field in the tab order is Quantity. Actually these are the only two fields in the tab order for the moment, just to simplify for trouble-shooting purposes.


              When the user tabs over to Quantity, Product Title, Price and Extended Price fill in automatically. A Discount may be manually entered.


              After entering a Quantity, tabbing out of that field triggers an OnObjectKeystroke script. This was taken from a suggestion of yours that I saw elsewhere, where you recommended against using OnObjectExit.


              This script navigates to the Products table to verify the existence of the Product ID and quantity in inventory. If there is a sufficient quantity, it subtracts them from inventory.


              Then it's back to the Invoice Entry table.


              So there are three possibilities:

              - Product ID does not exist - deletes the row and should ultimately leave user in a blank row in the Product ID field --- leaves user in Qty field instead

              - Insufficient quantity on hand - should clear out Qty and leave user in Qty field --- works as intended

              - Sufficient quantity on hand - should take user to the next row in the Product ID field--- leaves user in Qty field instead


              Note that I originally had set it up so that the search for the Product ID's existence was triggered OnObjectKeystroke when leaving the Product ID field (much more logical). But I thought I'd better sort out my issues with one script before I dared to add another into the mix... !


              Sorry for the hassle, but would you be so kind as to take a look and see where I'm going wrong?


              If [ Get (TriggerKeystroke) = Char (9) ]

              Set Variable [ $row; Value:Get (ActivePortalRowNumber) ]
              Set Variable [ $productID; Value:Product Sales Records::Product ID ]
              Set Variable [ $qtysold; Value:Product Sales Records::Product Qty Sold This Invoice ]

              Go to Layout [ “PRODUCTS (books & other)” (Products) ]
              Enter Find Mode [ ]
              Set Field [ Products::Product ID; $productID ]
              Perform Find [ ]
              Set Variable [ $qtyonhand; Value:Products::Qty On Hand ]
              If [ Get(FoundCount) = 0 ]

              Go to Layout [ “INVOICE ENTRY” (Invoices) ]

              Show Custom Dialog [ Message: "Product ID does not exist."; Default Button: “OK”, Commit: “No” ]

              Go to Object [ Object Name: "ProductSalesPortal" ]

              Go to Portal Row [ $row ] [ No dialog ]

              Perform Script [ “Delete Invoice Line Item: Product (Add Back to Inventory)” ]

              Exit Script [ ]
              Else If [ Get(FoundCount) > 0 and $qtysold > $qtyonhand ]

              Go to Layout [ “INVOICE ENTRY” (Invoices) ]

              Show Custom Dialog [ Message: "There are only " & $qtyonhand & " of this product in inventory."; Default Button: “OK”, Commit: “Yes” ]

              Go to Object [ Object Name: "ProductSalesPortal" ]

              Go to Portal Row [ $row ] [ No dialog ]

              Set Field [ Product Sales Records::Product Qty Sold This Invoice; "" ]

              Exit Script [ ]
              Else If [ Get(FoundCount) > 0 and $qtysold ≤ $qtyonhand ]

              Insert Calculated Result [ Products::Qty On Hand; $qtyonhand - $qtysold ] [ Select ]

              Commit Records/Requests

              Go to Layout [ “INVOICE ENTRY” (Invoices) ]

              Go to Object [ Object Name: "ProductSalesPortal" ]

              Go to Portal Row [ $row+1 ] [ Select ]

              Go to Field [ Product Sales Records::Product ID ] End If

              End If


              Although it seems to me that you are recommending against this entire approach, I'm not a super-experienced developer and don't see how to retrieve and update the info from the other table without navigating there... is this what I should really be learning to do here today? ;-)


              many thanks again!


              • 4. Re: go to portal row script step not working

                The immediate problem appears to be this step:


                Exit Script [. ]


                When certain triggers are tripped, the script assigned to that trigger is performed and then the event that tripped the trigger is processed. So you press a key that exits the field, and first the script does its thing and puts the focus in a specified field, but then the original keystroke event is processed and the cursor is moved to a different field.


                If you change the step to be:


                Exit Script [ False ]


                The pending event is canceled and the cursor stays where the script put it. To learn more about this, see "Setting Up Script Triggers" in Help.


                You are correct that I would not use this method to access data in the products table. Assuming this relationship:


                Invoices ---< Product Sales Records


                I would add:


                Product Sales Records >---- Products


                Product Sales Records::Product ID = Products::Product ID


                This way, simply entering or (better) selecting a product ID in Product Sales Records::Product ID links that portal record to the correct Product record and as long as the focus remains on that row, your script can refer to products to access info from the correct product record.



                1) You may need to use a new occurrence of Products with a different name if you have already placed Products elsewhere in your relationship graph.


                2) I almost always use Set Field instead of Insert Calculated Result given this step's brittle characteristics.

                • 5. Re: go to portal row script step not working

                  Adding the relationship between Product Sales Records and Products and avoiding all that navigation did indeed do the trick.


                  I look forward to spending some quality time ferreting out other extraneous uses of navigation throughout all my solutions :-)


                  Duly noted about choosing Set Field over Insert Calculated Result.


                  I am very much obliged to you for all your help, sir!