12 Replies Latest reply on May 12, 2017 8:51 PM by DouglasBenn

    How do you display new contents in a field with a script?

    DouglasBenn

      I apologize in advance with a very simple question that I have not been able to answer even after searching for about 1 day. I have written a script trigger which works in placing concatentaed text in a field. However, I cannot get the layout to update the field display. After the trigger runs I can force an update by manually clicking the field.

      The script is shown below and  triggers OnObjectEnter

      Screen Shot 2017-05-11 at 8.03.07 PM.png

      Thank you in advance.

       

      Douglas

        • 1. Re: How do you display new contents in a field with a script?
          TSPigeon

          DouglasBenn:

           

          Thank you for your post!

           

          You might use a commit records/requests after the Set Field script step. However, I'm not seeing this behavior one MacOS or Windows with FileMaker Pro 15 or FileMaker Pro 16 following these steps:

          1. Created "test.fmp12"

          2. Created "field"

          3. Created script "SetField" with a single setp: Set Field [ "field" ; "TestData"]

          4. Set OnObjectEnter Trigger for "field" to run "TestData"

          5. Entered Browse Mode and clicked into "field"

          -"TestData" was displayed without additional action

           

          Are you able to reproduce this issue in a new file?

          Is there any additional information that might help to reproduce?

           

          TSPigeon

          FileMaker, Inc.

          • 2. Re: How do you display new contents in a field with a script?
            TSPigeon

            I'm also going to move this thread from the FileMaker Community Feedback Space (which is specifically for input on the Community itself) to the Discussions Space where you should receive more views and potentially more feedback on this topic!

             

            TSPigeon

            FileMaker, Inc.

            • 3. Re: How do you display new contents in a field with a script?
              philmodjunk

              Neither commit records, nor go to object should be needed. Perhaps this field has been defined as type Number instead of type text? You can open Manage | Database to check this.

              • 4. Re: How do you display new contents in a field with a script?
                DouglasBenn

                Dear TSPigeon,

                 

                Thank you for your suggestion and moving this to Discussion. As you can see this is my first posting!

                 

                I tried adding "commit records/requests" but it made no difference.

                 

                Screen Shot 2017-05-12 at 11.03.02 AM.png

                I also tried Philmodjunk's suggestion and checked the database entry which is of type text not number. The DB has a comment that the field is indexed. Could that make a difference?

                 

                When I click on the layout box it updates the entry. Is there a script command which is equivalent to clicking a box?

                 

                I will try creating a new file and see if the error reproduces.

                 

                Thanks for you suggestions.

                 

                Douglas

                • 5. Re: How do you display new contents in a field with a script?
                  philmodjunk

                  What script trigger are you using? If you are using OnObjectEnter, it would automatically update the field when you click it. If it's OnObjectExit on a different field or object, then clicking into this field could also cause an update.

                   

                  Note that OMFR Reports III::Clinical Information is not an object name. Object names are assigned to layout objects using the name box in the inspector and can be used to name any object on your layout. (Though some objects cannot receive the "focus" and thus naming them is not of any use.)

                  • 6. Re: How do you display new contents in a field with a script?
                    DouglasBenn

                    Dear Phil,

                     

                    Thank you for following up.

                    I am using OnObjectEnter.

                    Screen Shot 2017-05-12 at 12.27.49 PM.png

                     

                    I thought that Data field OMFR Reports III:: Clinical Information was an object but I obviously must read up more about Objects. Should I check the box below "Select entire contents on entry" ? Will that make a difference?

                     

                    Screen Shot 2017-05-12 at 12.33.37 PM.png

                    Thank you.

                     

                    Douglas

                    • 7. Re: How do you display new contents in a field with a script?
                      siplus

                      once you gave a real name to your field, you can use the "Refresh Object" script step.

                      • 8. Re: How do you display new contents in a field with a script?
                        philmodjunk

                        You use the name box on the position tab to give a layout object a name. But your design is doing exactly what you set it up to do.

                         

                        You are clicking into the field and this trips OnObjectEnter--the trigger you set up and the script then enters data into the field--exactly as you designed it to and exactly as you describe here.

                         

                        Let's back up a step.

                         

                        What do you want to accomplish here?

                        • 9. Re: How do you display new contents in a field with a script?
                          DouglasBenn

                          Dear Phil and Siplus,

                           

                          As suggested I named the object "ClinInfo" in the Name box under Position tab. I also added Refresh Object to the script with object Name "ClinInfo".

                           

                          Screen Shot 2017-05-12 at 2.06.38 PM.png

                          Screen Shot 2017-05-12 at 2.05.26 PM.png

                           

                          I ran the script with the same result (shown below) which is it shows me the text ("Bisphosphonates") that is stored in OMFR Reports III::Clinical Information before the script concatenates text from two other fields and then writes it back into Clincial Information field

                           

                          Screen Shot 2017-05-12 at 2.14.14 PM.png

                           

                          After I manually put my cursor just to the right of "Bisphosphonates" in the box and click the mouse, it shows the text from the concatenation in the filed (as below).

                           

                          Screen Shot 2017-05-12 at 2.17.03 PM.png

                          So what I would like is to avoid having to manually click the box to show the concatenated text.

                           

                          To answer Phil's question: I am importing a patient record from a comma separated text string .txt file. I have a template in FM Pro that links the text fields to the database fields and FMP correctly imports and places the text into the correct fields. Some of the fields are not included in the layout so I use the script to directly access the database fields, concatenate them into a new string which is put into the field OMFR Reports III::Clinical Information. Everything works correctly except I have to manually click the Clinical Information box to get the concatenated string to appear.

                           

                          Any ideas?

                           

                          Guys I appreciate your time!

                           

                          Douglas

                          • 10. Re: How do you display new contents in a field with a script?
                            philmodjunk

                            To repeat:

                             

                            You are clicking into the field and this trips OnObjectEnter--the trigger you set up and the script then enters data into the field--exactly as you designed it to and exactly as you describe here.

                             

                            Thus it is doing exactly what you designed it to do even if this may not be what you want it to do. If you want a different result, you need a different approach. A script trigger isn't the only way to get this data, you don't even have to copy it into a different field as you can simply reference the data in the table from the OMFR Reports III table. You can use merge text to combine the data with additional text such as the period. I'm not saying that this alternative is the best approach, just pointing out that you have other options available.

                            • 11. Re: How do you display new contents in a field with a script?
                              DouglasBenn

                              Dear Phil,

                               

                              I will try what you suggest. I am not quite sure how you reference data in the Reports table?

                               

                              However, I will dig around.

                               

                              Thank you.

                               

                              Douglas

                              • 12. Re: How do you display new contents in a field with a script?
                                DouglasBenn

                                Dear Phil,

                                 

                                Merge text worked fine.

                                 

                                Thank you!

                                 

                                Douglas