8 Replies Latest reply on Dec 20, 2010 12:05 PM by projay

    Help with script to work in portal rows.

    projay

      Title

      Help with script to work in portal rows.

      Post

      This script basically worked with a repeating panel...
      Since then i have changed from a repeating panel to a portal

      How can I make this work with  PORTAL ROWS.

      All this does is simply copies a value from FIELD_A and puts it
      in FIELD_B if a the value in FIELD_C is =>1

      This is a loop script so it stops coping the value if FIELD_C is Empty or has a 0.

      Any help would be great.

      Thanks Jay.

      fenton_script_test.jpg

        • 1. Re: Help with script to work in portal rows.
          FentonJones

          I'm going to just write this generically. You'll have to fill in your specific data. I'm going to go to the portal's records, on a layout of its base table. I usually do it that way, rather than work within a portal. It seems you're unfamiliar with the general method. It could also be written to work within the portal also. You can see the similarity between all these loop methods.

          Commit Records [ no dialog ]
          If [ not IsEmpty ( portal's relationship::key field ) ]
          Go To Related Record [ portal's relationship; portal's base table's layout* ]
          Loop
          If [ some field ≥ 1 ]
          Set Field [ table::whatever field; whatever ]
          End If
          Go To Related Record [ Next; Exit after last ]
          End Loop
          Commit Records [ no dialog ]
          Go to Layout [ original ]
          End If

          *This could be any layout belonging to any table occurrence of the portal's base table; wherever. Usually you use the main one, or, if you need to use relational tests or access, one which has them; preferably one without script triggers which might interfere.

          • 2. Re: Help with script to work in portal rows.
            projay

            How can you make this work within a portal do you have to acivate the portal?

            Jay

            • 3. Re: Help with script to work in portal rows.
              projay

              I tried that and it didnt work...I was going to attach pic of script but that option is not available.

              • 4. Re: Help with script to work in portal rows.
                FentonJones

                No. Since you are wanting to run a Loop to process all the rows/records of the portal, you do not need to be in it. Basically a portal is just a FileMaker device which can show the related records of another (or the same) table, filtered by a relationship. By using the Go To Related Record [ portal's relationship; layout of the portal's records ] you are going to the records of that portal directly, on their own layout. It is the same records you see in the portal. You can then process them directly. 

                But since you ask; yes, you could do it within the portal also. It looks almost the same. (You do not really need to check that the portal is not empty, but it's best to get into the habit.)

                Commit Records [ no dialog ]
                If [ not IsEmpty ( portal's relationship::key field ) ]
                Go to Field [ portal's relationship::field ] // to get the right portal
                Go to Portal Row [ First ]
                Loop
                If [ portal relationship::field ≥ 1 ]
                Set Field [portal relationship::whatever field; whatever ]
                End If
                Go To Portal Row [ Next; Exit after last ]
                End Loop
                Commit Records [ no dialog ]
                End If

                • 5. Re: Help with script to work in portal rows.
                  projay

                  It only sets the field in the first row the other rows remain unchanged. 

                  This won't let me attach a pic of how I set it up accrording to your info. Any suggestions.

                  Jay.

                  • 6. Re: Help with script to work in portal rows.
                    FentonJones

                    That loop definitely works, as I built it in an example file to make sure. You could upload another screenshot. Are you sure the other rows match your test before changing the value?

                    • 7. Re: Help with script to work in portal rows.
                      projay

                      Hi Fenton i uploaded the new image to the original post.

                      Check it out and let me know can't seem to figure it out. It only sets the information in the first portal row.

                      Jay.

                      • 8. Re: Help with script to work in portal rows.
                        projay

                        Well Fenton You were correct, IT WORKS!

                        Sorry for the headache....I must of added in more than need.

                        Jay.