1 2 Previous Next 16 Replies Latest reply on May 1, 2014 11:13 AM by disabled_ntaylor

    Perform Script on Server not applying text formatting

    aewerdt

      Summary

      Perform Script on Server not applying text formatting

      Product

      FileMaker Server

      Version

      13.0.1

      Operating system version

      Windows Server 2008 R2

      Description of the issue

      Text formatting functions not being applied (or not being returned in the Exit Script result). If I perform the script on the client (FileMaker Pro or FileMaker Go), the formatting is applied and returned correctly. If the script is ran using PSOS, then no formatting is applied.

      Steps to reproduce the problem

      PSOS
        - Set Variable [ $var; Value: TextColor ( fieldName ; RGB ( 60 ; 60 ; 60 ) )] or [ TextStyleAdd ( fieldName ; Italic ) ]
      - Exit Script [ Result: $var ]

      Expected result

      Formatted text

      Actual result

      Unformatted text

        • 1. Re: Perform Script on Server not applying text formatting

          Aaron Ewerdt: 

               Thank you for the post.

                

               Globals are session based and evaluate in the context of the location at runtime. 

                

               Add a "Set Field" script step before the Exit Script and place the value of the global into a field. Does the field's text have the text formatting?

                

               Lastly, if the intention was to combine the text formatting, try this syntax instead of the "or" operator:

                

               TextColor ( TextStyleAdd ( Field ; Italic ) ; RGB ( 60 ; 60 ; 60 ) )

                

               TSFalcon

               FileMaker, Inc.

          • 2. Re: Perform Script on Server not applying text formatting
            aewerdt

                 Sorry if my initial example was confusing. I am setting the variable inside the server-side script, and then returning that variable as an Exit Script result, and then setting the client side variable using Get ( ScriptResult ), so variable type shouldn't matter. Also, the "or" operator was supposed to show that I tried various text formatting functions with the same result, not that I incorrectly combined that formatting.

                 Anyways, I reran the test so that the PSOS sets the value of the server-side variable to a field as well as returning it using Exit Script. The result is that the text set to the field is formatted correctly, but the text returned to the client (as seen when the client uses Get ( ScriptResult ) ) is not formatted.

                 If on the client, I change the PSOS step to just a regular Perform Script step, the text returned from Exit Script is still formatted correction.

                 So it looks like the issue is not that the server isn't formatting the text, it is that the server's Exit Script Result doesn't pass formatted text.

            • 3. Re: Perform Script on Server not applying text formatting
              philmodjunk

                   As a work around, you could return a script result such as:

                   Exit Script ["Let ( $VariableNameHere = TextColor (" & Table::fieldName & " ; RGB ( 60 ; 60 ; 60 ) ) ; 1 ) "]

                   Then

                   Set Variable [$Dummy; value: Evaluate ( Get ( ScriptResult ) ) ]

                   will assign the formatted text to $VariableNameHere as a side effect of the above set variable step.

              • 4. Re: Perform Script on Server not applying text formatting
                aewerdt

                     I wish. Except my example is an extremely simplified version of what I am actually doing, which is more along the lines of:

                     Go to Layout ["Person" (Person)]
                     Loop
                        GTRR [Show only Related Records; From table:"Treatment"; Using layout:"Treatment" (Treatment)]
                        Loop
                           If [$previous != Person::ID]
                              Set Variable [$formattedText; Value:$formattedText & "|" & Person::name & "      " & TextColor ( Person::Phone ; RGB ( 120 ; 120 ; 120 )]
                              Set Variable [$IDs; Value:$IDs & "|" & Person::ID]
                              Set Variable [$type; Value:$type & "|" & "Person"
                           End If
                           Set Variable [$formattedText; Value:$formattedText & "|" & "      " & TextStyleAdd ( Treatment::name ; Italic )]
                           Set Variable [$IDs; Value:$IDs & "|" & Treatment::ID]
                           Set Variable [$type; Value:$type & "|" & "Treatment"
                           Set Variable [$previous; Value:Person::ID
                           Go To Record [Next; Exit after last]
                        End Loop
                        Go to Layout ["Person" (Person)]
                        Go To Record [Next; Exit after last]
                     Exit Loop
                     Exit Script [Result: List ($formattedText; $IDs; $type)]

                     And then from the parent client-side script:
                     Set Variable [$$formattedText; Value:Substitute ( GetValue ( Get ( ScriptResult ) ; 1 ; "|" ; ¶ )]
                     Set Variable [$$IDs; Value:Substitute ( GetValue ( Get ( ScriptResult ) ; 2 ; "|" ; ¶ )]
                     Set Variable [$$type; Value:Substitute ( GetValue ( Get ( ScriptResult ) ; 3 ; "|" ; ¶ )]

                     And even that example is somewhat simplified, but the end result is that $formattedText is a dynamically formatted list that contains both Person and indented Treatment values, and formatting all that after the fact doesn't sound too easy (unless I am missing something), at least not using your workaround.
                      

                • 5. Re: Perform Script on Server not applying text formatting
                  aewerdt

                       @PhilModJunk,

                       I just re-read your post, and actually understand it now. Maybe I can redo my script so that it puts all the formatting as part of the actual text, and then Evaluate that entire mess client-side. I think I will wait to see if there are any other suggestions first though before I attempt that rewrite.

                  • 6. Re: Perform Script on Server not applying text formatting

                    Aaron Ewerdt: 

                         Thank you for the reply.

                          

                         "A local variable can only be used in script steps in the currently executing script. The value in a local variable is cleared when the script exits."

                          

                         This is documented in the help in the following places:

                          

                    Using variables

                          

                    Set Variable

                          

                         When a script is performed on the server, those variables belong to the host; hence, the inability to pass those local variables to the client.

                          

                         TSFalcon

                         FileMaker, Inc.

                    • 7. Re: Perform Script on Server not applying text formatting
                      aewerdt

                           @TSFalcon:

                           I know all that, but what does it have to with my problem?

                           Client-side:
                           Perform Script On Server

                           Server-side:
                           Set a variable $server-var and return the value of that variable to the client using Exit Script [Result; $server-var]

                           Client-side:
                           Set a variable $client-var using Get ( ScriptResult )

                           The result is $client-var = $server-var, but with all text formatting stripped out that was done server-side, and I want that formatting.
                            

                      • 8. Re: Perform Script on Server not applying text formatting

                        Aaron Ewerdt: 

                             Thank you for the reply.

                              

                             The FileMaker Server has its own local variables. Those are cleared upon exiting the script. A FileMaker Pro client cannot pull the value of the local variable from the FileMaker Server host because its local variables are not the same. 

                              

                             Upon exiting the script $var no longer exists for the next script to pull as a result.

                              

                             As in your example, this is how we expect the process to work: 

                              

                             The Get ( ScriptResult ) function is going to look for $server-var and when the client doesn't see a variable with that name in its session, it instead creates the local variable with no data. 

                              

                             TSFalcon

                             FileMaker, Inc.

                        • 9. Re: Perform Script on Server not applying text formatting
                          aewerdt

                               But my client doesn't create a local variable with no data. It gets data by using Get ( ScriptResult ) from the server.

                               My problem is that on the client, when it issues a PSOS script step with "Wait for completion" set. The server does a $server-var = FormatText ( Field ; Italic ) and then an Exit Script [Result; $server-var].

                               When my client does a $client-var = Get ( ScriptResult ), $client-var isn't empty. It contains the data that $server-var contained, only it is no longer formatted.

                          • 10. Re: Perform Script on Server not applying text formatting

                            Aaron Ewerdt: 

                                 Thank you for the reply.

                                  

                                 I am unable to replicate. Even if I use Perform Script on Server and Exit Script with a Global ($$) variable, then FileMaker Pro does not pull anything using Get ( ScriptResult ). 

                                  

                                 Could you provide a sample file that replicates? If so, please check your inbox at the top of this page for instructions on how to submit the file for testing.

                                  

                                 TSFalcon

                                 FileMaker, Inc.

                            • 11. Re: Perform Script on Server not applying text formatting
                              philmodjunk

                                   Quoting from FileMaker Help:

                              Wait for completion pauses the script on the client until the sub-script called by Perform Script On Server is completed on the host. Wait for completion must be selected to pass a script result or error code from the host to the client. Use the Get(ScriptResult) function to capture a result or the Get(LastError) function to capture an error code.

                              • 12. Re: Perform Script on Server not applying text formatting
                                aewerdt

                                     @PhilModJunk

                                     That is exactly what I am doing. Thanks for pointing out the actual documentation so that I know I am not crazy.

                                     @TSFalcon

                                     I'm preparing a sanitized sample file of my solution now. Will send you an e-mail shortly...

                                • 13. Re: Perform Script on Server not applying text formatting
                                  philmodjunk

                                       Actually, I was trying to point that out to TSFalcon as a possible reason why he was not getting any script result.wink

                                  • 14. Re: Perform Script on Server not applying text formatting

                                    Aaron Ewerdt: 

                                         Thank you for the reply and sample file.

                                          

                                         In my tests the "Wait for completion" checkbox was checked. Borrowing your use of the List ( ) function did allow FileMaker Pro locally to maintain the text formatting; however, when run server-side, the text returns but not the formatting.

                                          

                                         Since I am able to replicate, I forwarded a report to Testing and Development for review. 

                                          

                                         TSFalcon

                                         FileMaker, Inc.

                                    1 2 Previous Next