7 Replies Latest reply on May 20, 2015 9:38 AM by DavisSmith

    Emailing script problem

    DavisSmith

      Title

      Emailing script problem

      Post

      So I have a table with a couple different fields that I need to email daily to coworkers. I have my script set up so that the fields are formatted by adding a "N/A" with some space if the field is empty and if the field has data in it, it adds spaces until the length of each "field" is 18. If the field length is over 18 it just copies the field over as is. The problem I've been running in to is that most of the fields copy over just fine but 2 of the fields copy over as blank. The fields that copy blank have data in them. If they were empty they would show up as "N/A" but I'm confused as to why they are showing up blank whenever they are emailed. I should mention that I had to add these fields into the table and that all the fields that copy correctly were already in the table before I started working on this script. 

        • 1. Re: Emailing script problem
          philmodjunk

          I can think of several possible reasons, but can't tell if they are possible as you don't tell us very much about how you have set this up.

          I have my script set up so that the fields are formatted by adding a "N/A" with some space if the field is empty and if the field has data in it, it adds spaces until the length of each "field" is 18.

          Is this a calculation field? Set Variable? A calculation inside the Send Mail Dialog? or ??? Exactly what calculation do you use? Can you post it? (There's more than one way to test to see if a field is empty.)

          but 2 of the fields copy over as blank.

          Are these fields in the same table as those that are copying over correctly? What data type is specified for them?

          • 2. Re: Emailing script problem
            DavisSmith

            The calculation for setting them to "N/A" is done in the script to email the tables contents. My script for emailing loops through each field in the table and adds it to a variable that gets emailed. Heres what one iteration through a field looks like (ill show you one of the fields that isnt working):

            If[IsEmpty (Stone For Customers::Color)]

            Set Variable [$color; Value: "N/A              "]

            Else If [Length (Stone For Customers::Color ) < 18]

            Loop

            Exit Loop If [Length($color) >18]

            Set Variable [$color; Value: $color & " "]

            End Loop

            Else

            Set Variable [$color; Value: Stone For Customers::Color & "  "]

            End If

             

            Yes all of the fields that I'm copying over are in the same table. I have date, text, and number types and I have fields with each of those types that copy over correctly but the fields that don't copy over are text type.

            • 3. Re: Emailing script problem
              philmodjunk

              Don't see anything obviously wrong. If the fields that were blank were from a different table, a relationship issue might be at fault but your last answer rules that out.

              Do you use FileMaker Advanced? If so, enable the script debugger and data viewer and step through the script while monitoring field and variable values to see where this goes wrong. This could be something as simple as mistyping a variable name in a calculation somewhere.

              Here's a much simpler way to add trailing characters, BTW:

              Set Variable [$Color; value: If ( Length ( Stone For Customers::Color ) < 19 ) ; Left ( $Color & "                  " ; 18 ) ; Stone For Customers::Color )  ]

              • 4. Re: Emailing script problem
                DavisSmith

                Ok I'll give it a try and thanks for the tip. Where can I find documentation on the syntax you just used for that function?

                • 5. Re: Emailing script problem
                  DavisSmith

                  Also I unfortunately don't have FM advanced so I'm pretty much all out of ideas. I could post the entire script if you want to look and see if you notice anything? If thats the case whats an easy way to copy the script over because I don't want to type out the entire thing.

                  • 6. Re: Emailing script problem
                    philmodjunk

                    You might consider upgrading to advanced. The added tools are well worth the $$ you have to spend to get this version if you plan on producing more than a very basic simple database solution.

                    What you can do without the debugger, is insert temporarily Show Custom Value dialogs into different points in your script and use the dialog to display the value of fields and variables. That's not nearly as nice as the debugger/data viewer set up, but may enable you to spot where a variable is not getting the expected value.

                    All the functions that I used in my last suggestion can be looked up in FileMaker Help. You may find it generally instructive to look up "functions" in help and spend some time reviewing the list of available functions and what they can do. But they won't solve your current problem, just make your script simpler.

                    The Get function is a "swiss army knife" function that is an entire library of additional tools that is well worth researching from time to time. You can get a full listing for this function in Help as well.

                    To post a script to the forum:

                           
                    1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
                    2.      
                    3. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
                    4.      
                    5. If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                    6.      
                    7. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                    • 7. Re: Emailing script problem
                      DavisSmith

                      Nevermind, fixed it. I had left off a statement on both of those.