5 Replies Latest reply on Apr 30, 2010 11:21 AM by icecreamboy

    Insert text affecting other portal rows



      Insert text affecting other portal rows




      I'm using FileMaker 11 and Windows XP.


      I have a portal which uses a button with a script to fill in several fields of the row with spaces via the "Insert Text" script function. However, when multiple related records exist in the portal, the button starts to behave oddly. It inserts the text (spaces) into fields belonging to other rows of the portal. Is there a script function that directs the button to apply its script to the same row that the button is in?


      Thanks! :)

        • 1. Re: Insert text affecting other portal rows

          After some more testing I realized the first "Insert Text" command happens correctly, then the portal scrolls back up itself and performs the remaining "Insert Text" commands to the fields belonging to the top row of the portal. Is there any way to prevent it from scrolling up the portal?

          • 2. Re: Insert text affecting other portal rows

            Why don't you post your script?


            It would also help to know what's your purpose in this - filling fields with spaces doesn't sound like something worth doing in the ordinary course of thing.

            • 3. Re: Insert text affecting other portal rows

              Hi comment, sorry I didn't think about that! :P


              So the purpose of this is that I need a diagram of an anatomical figure that needs to let the user mark anywhere on the body for diagnostic purposes. Since FileMaker doesn't have a native tool to let users draw in Browse mode, my solution was to put the figure as a background image, and put an empty field over it. This field is filled with spaces and has an "OnObjectEnter" script trigger that basically does "if character after clicked spot is a space, replace the space with an x. if it's an x, make it a space. then commit record." In effect this let me click anywhere on the space-filled field and it'll put an "x" and I can click the "x" again to make it go away. (Someone else thought of this solution, which I thought was perfect for this.)


              The slight problem came in because the anatomical figure is rather large, covering almost a full page. For some reason, when I'm zoomed in at 200% (which I intend to be the default zoom), the space-filled field extends only about 1/3 of the page no matter how big I make the field in Layout Mode. The solution I did for this was make 3 empty fields that cover the figure.


              The button that fills the 3 fields with spaces has this script:


              Insert Text [Select; Field1; " _lots of spaces_ "]

              Insert Text [Select; Field2; " _lots of spaces_ "]

              Insert Text [Select; Field3; " _lots of spaces_ "]


              This works fine when there's only 1 row in the portal. However, when there's 2 or more rows in the portal, only the first line (Field1) fills the appropriate row's Field1, while Field2 and Field3 of the top-most row gets filled with spaces instead of the Field2 and Field3 of the active row.


              I did notice that if I rearrange the lines in the script, it's always the first line's Field# that works properly, which makes me think that after the first line's "Insert Text" command, the portal's active row gets reset to the top one, where the remainder of the "Insert Text" commands take place.

              • 4. Re: Insert text affecting other portal rows

                First, you should be using Set Field[] rather than Insert Text[].

                Also, I didn't understand the problem with the field size - it seems to me you simply don't have enough spaces in the field to cover the entire area.

                And I am not at all sure where a portal comes into this.

                Anyway, to address your question: if the button is correctly placed in the portal, and the ONLY action is Insert Text[], the action should take place in the clicked row.

                So either your button is not entirely in the first row of the portal, or something causes the portal to lose focus. I believe there's a OnEnter script trigger attached to the field/s? If so, Insert Text will definitely trigger it (one more reason to use Set Field[] instead).



                icecreamboy wrote:

                Someone else thought of this solution


                That someone is Daniele Raybaudi - give credit where credit is due:




                • 5. Re: Insert text affecting other portal rows

                  Ah thank you comment! The problem was the OnEnter trigger that apparently comes into effect after Insert Text but not Set Field. And sorry for not specifically linking to Daniele Raybaudi's post.