1 2 3 Previous Next 34 Replies Latest reply on Jul 4, 2017 5:40 PM by Oliver_Reid

    Get Portal Row Number




      I have a portal with about 10 rows in the invoice.

      I'm try to capture the portal row value (technician's name) into my script, but it somehow always capture the first row, and skip the rest of the portal rows.

      I'm not sure if "GetNthRecord" is the best method for this job.


      The technician name data is display from Line Items, but its value is a global field.






      Set Variable [ $oldTech; Value:GetNthRecord ( Line Items::Technician;1 ) ]

      Set Variable [ $invoiceID; Value:Invoices::ID ]



      #Remove invoice ID from the the current technician in Turn Rotation

      Freeze Window
      Go to Layout
      [ “Turn Rotation” (Turn Rotation) ]

      Enter Find Mode [ ]
      Set Field [ Turn Rotation::Date; Get (CurrentDate) ]

      Set Field [ Turn Rotation::Technician; $oldTech ]

      Set Error Capture [ On ]

      Perform Find [ ]

      Go to Record/Request/Page

      [ Last ]

      If [ Turn Rotation::Invoice_1 = $invoiceID ]

      Set Field [ Turn Rotation::Invoice_1; "" ]

      Else If [ Turn Rotation::Invoice_2 = $invoiceID ]

      Set Field [ Turn Rotation::Invoice_2; "" ]

      Else If [ Turn Rotation::Invoice_3 = $invoiceID ]

      Set Field [ Turn Rotation::Invoice_3; "" ]

      Else If [ Turn Rotation::Invoice_4 = $invoiceID ]

      Set Field [ Turn Rotation::Invoice_4; "" ]

      Set Field
      [ Turn Rotation::Invoice_5; "" ]

      End If



      #update new technician on Turn Rotation

      Freeze Window

      Go to Layout [ “Services Invoice” (Invoices) ]

      Commit Records/Requests

      [ Skip data entry validation; No dialog ]
      Perform Script [ “Update Technician v1.1 [Invoices]” ]

      Refresh Portal [ Object Name: "technicians.portal" ]

      End If
      Exit Script
      [ ]


        • 1. Re: GetNth Record

          What you show is a getNthRecord call that always specifies the first related record. That's what the 1 is for after all.


          what user action selects a technician?

          • 2. Re: GetNth Record

            Hello Phil,


            The technician name is a drop-down list.

            I setup the script trigger with OnObjectExit.

            What I want is whether the technician is change in 1st, 2nd, or nth portal row I'm able to capture that technician name so I can use it in another table.



            • 3. Re: GetNth Record

              Yes but that is not clear as to exactly what sequence of events is taking place.


              Is the drop down list list located in the portal row?


              Do you want the act of selecting from the drop down list to also run this script?

              • 4. Re: GetNth Record

                Yes, and yes.

                • 5. Re: GetNth Record

                  Then you don't need getNthRecord.


                  The act of selecting the technician puts the focus on that portal row. As long as nothing happens to change the focus, you can directly reference any field from the portal row's record.

                  • 6. Re: GetNth Record

                    I"m try to use GetActiveFieldContents, but it didn't work out like I want it.

                    • 7. Re: GetNth Record

                      I didn't say to use getActiveField contents, I said that you can directly reference any field of the portal row's record until something changes the focus away from the portal row. Sometimes, that requires setting variables to values from the portal row at the very beginning of your script to be sure to capture that data before a commit records, new record, go to layout, new window or other action changes the focus.


                      Set Variable [$OldTech ; LineItems::Technician ]


                      Will set $OldTech to the current value of LineItems::Technician assuming that your portal is to LineItems and that your value list is located inside the portal row.


                      Hmmm but maybe you want the value of Technician BEFORE you change it by selecting a technician from the value list? Depending on which field is formatted with that value list, that may need a different trigger to capture that value in a separate script.

                      • 8. Re: GetNth Record

                        Will set $OldTech to the current value of LineItems::Technician assuming that your portal is to LineItems and that your value list is located inside the portal row.

                        That's what I have in my setup.


                        I create two scripts: script 1 = capture old technician, and remove it from another table.

                        Script 2 = add new technician to another table.


                        I've tried script trigger on OnObjectEnter for script 1, and OnObject Exit for script 2, but they didn't work well.

                        • 9. Re: GetNth Record

                          GetNthRecord is a function that rewards some close study of the FM Help page. Since you are using a portal I assume you are using it to extract data from a related table, so the key is probably this bit:

                          "GetNthRecord of a related table returns the Nth record of the related set (relative to the current record), based on the sort order of the relationship"

                          What this means, for example, is that if you want to pull data from a specific portal row you may need to use Get(ActivePortalRowNumber) first and then apply that as your number in the GetNthRecord function.

                          • 10. Re: GetNth Record

                            OnObjectEnter can be used to set a variable to the value of field before a user modifies it, but you have to be careful of drop down lists and pop up menus. The value selection on these takes place before the trigger is tripped, so the trick is to pass the value of the field as the script parameter and usevthis step to capture the original value.


                            Set Value [$$OldTech ; get ( scriptParameter ) ]


                            You also probably need this to be a global variable so that you can capture the value in one script and use it in another.

                            • 11. Re: GetNth Record

                              Hello Phil,


                              I'm not sure how to use get ( scriptParameter ) for OnObjectEnter.

                              The value of the drop-down list is dynamic.

                              Can you explain a little more?


                              • 12. Re: GetNth Record

                                This is to capture the value of the field before selecting a value from that list changes it.


                                So if LineItems::Technician is the field that you've formatted with the drop down list and want to capture the value of this field before the user selects a different technican.


                                You'd enter LineITems::Technician as the script parameter for the OnObjectEnter trigger.


                                Then the one line script that I suggested earlier will capture the value of the field before the latest value select action changes it.

                                • 13. Re: GetNth Record

                                  If I use LineITems::Technician as the script parameter for the OnObject Enter trigger for script 1 to capture the old technician's name with Set Value [$$OldTech ; get ( scriptParameter ) ],


                                  then perform script 2 with the same line code with Set Value [$$OldTech ; get ( scriptParameter ) ] ?

                                  • 14. Re: GetNth Record

                                    No, I am describing script 1 in what could be no more than a single step script, But I am not completely clear on what you are trying to accomplish here. In script 2, you would refer to the $$OldTech, that's why I have also changed this from $OldTech to $$OldTech. The second version is a global variable that will retain its value after the script exits. With $OldTech, the value does not persist when the script that created it exits.


                                    In your original post, I see one long script not two. Where does one end and the other begin?


                                    I can guess, but prefer not to.

                                    1 2 3 Previous Next