1 2 Previous Next 17 Replies Latest reply on Feb 15, 2017 11:49 AM by user28271

    Containers, and Scripting, and Jpegs... oh my!

    user28271

      In today adventure I have two container fields.

       

      Field 1 is container with the staff signature as a jpeg.

      Field 2 is a container on a vacation request form.  A script will SET the vacation request signature container to the contents of the related staff signature container.

       

      Sometimes it works fine.

      Sometime I get a icon of a JPEG file in the Vacation Request container field instead.

       

      If I go back to the staff card and cut&paste the signature back in and re-run the script it works. 

       

      But then the next time it is back to a JPEG file icon.

       

      Any thoughts?

        • 1. Re: Containers, and Scripting, and Jpegs... oh my!
          user19752

          If the file is hosted and Field2 is global storage, you need close the file and open it as local file to re-set field value.

          • 2. Re: Containers, and Scripting, and Jpegs... oh my!
            keywords

            It's quite likely to do with global storage. Best practice would be as follows:

            1.     Create a separate table to hold globals

            2.     Create a standard container field (i.e. not global) and keep the signature in there

            3.     Create a global container field which you populate from the standard container—you can use a script that inserts it into the global field, and run that script every time the file opens (use OnFirstWindowOpen script trigger)

            That will make sure the global always contains the image file.

             

            However, since you sometimes get an icon, sometimes the signature, sometimes nothing it is possible there is an issue with the image file itself. For what it's worth, I prefer to use a .png file for a signature because you can set that with a transparent background. You might try using a different file and see if that helps.

            • 3. Re: Containers, and Scripting, and Jpegs... oh my!
              user28271

              Thanks.  That is exactly how I have it working.  The Script sets the global fields with the non-global containers jpg.

               

              I might explore PNG, but will this work with Windows Clients?  I have had issues in the past with using png logo files on layouts.  When a Window client opened the file the png would not appear.

              • 4. Re: Containers, and Scripting, and Jpegs... oh my!
                keywords

                Might be a problem on Windows; I'm not sure. I know Win can be a bit ornery when it comes to that type of thing. You'd have to try it and see. You could also try .pdf format.

                • 5. Re: Containers, and Scripting, and Jpegs... oh my!
                  monkeybreadsoftware

                  A container contains several streams.

                  if you get a JPEG without a SIZE stream, FM will not display it.

                   

                  Our MBS Plugin function Container.GetTypes will tell you what's in the container, so you could verify that.

                  • 6. Re: Containers, and Scripting, and Jpegs... oh my!
                    keywords

                    Christian Schmitz wrote:

                    A container contains several streams  …  SIZE stream

                    That's new to me, Christian. Can you explain what a stream is, please? Is this part of the metadata? In what circumstances would there be no SIZE stream?

                    • 7. Re: Containers, and Scripting, and Jpegs... oh my!
                      monkeybreadsoftware

                      Well, you could of course simply read the plugin SDK documentation:

                       

                              // A BinaryData type is a collection of streams. Each stream has two parts, a TypeId and Data.

                              //              There can be multiple related streams, but there should never be more than one

                              //              stream of the same type.  Streams should not be empty.

                              // Container fields can be considered to be of type BinaryData when data is stored in the database

                              //          as opposed to objects inserted by reference (path of file as text).

                              //             

                              // To iterate through the streams of a BinaryData, use GetCount and then call GetIndex to

                              //              get the TypeID for each stream.

                              //

                              // To create a new BinaryData object, use the autoptr version to construct the object, then

                              //      Add() streams if you didn't use one of the auto populating constructors.

                              class BinaryData

                              {

                              public:

                                  // Here are some common QuadChar types you may encounter, and notes on required usage.

                                  // The actual format of the data should adhere to the standard documented by

                                  // the format creator.

                                  //

                                  //  "FNAM" is a filename stream. This is used either to display the filename of the file

                                  //          in the field (non-images or images that cannot be displayed) and for a initial

                                  //          suggested filename when exporting field contents. Please use the special accessors

                                  //          below ("GetFNAMData and AddFNAMData) to get a text representation of this data.

                                  //

                                  //  Images:

                                  //          { "JPEG", "GIFf", "EPS ", "META", "PNGf", "BMPf", "PDF " }

                                  //          Images must have at least a JPEG, GIFf, or PNGf stream in addition to any

                                  //          other image type. A "SIZE" stream is also required for FileMaker to display

                                  //          the image. Please use the special accessors below (GetSIZEData and AddSIZEData)

                                  //          to get the height and width values for the image.

                                  //

                                  // When generating other kinds of graphical data, use JPEG or PNGf for a preview,              

                                  // and the other format will be preferred if possible. For example, to generate        

                                  // a TIFF picture, you have to add "TIFF" and "JPEG" streams.           

                                  //

                                  //  Files:

                                  //          { "FILE" (binary file data), "ZLIB" (compressed file data), "FORK" (Mac only resource fork) }

                                  //          Compressed file data is compressed using zlib but using the gzip headers. Parameters used are:

                                  //              deflateInit2( ctx, Z_BEST_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY );

                                  //          Decompression also uses zlib set to detect zlib or gzip headers. Parameters used are:

                                  //              inflateInit2( ctx, 15 + 32 )

                                  //         

                                  //  Sound:

                                  //          { "snd " }

                                  //          Always Mac raw format.

                                  //

                                  //  Other types:

                                  //          { "MAIN" }

                                  //          When saving the contents of a container field to disk, FileMaker will first

                                  //          check if there is a MAIN stream and if present read the first four bytes as

                                  //          the QuadChar of the stream that is considered the main stream for the container.

                                  //          If this does not existed it falls back to the default rules for picking the

                                  //          main stream.

                      • 8. Re: Containers, and Scripting, and Jpegs... oh my!
                        keywords

                        Thank you. Will do my best to make sense of that.

                        • 9. Re: Containers, and Scripting, and Jpegs... oh my!
                          user28271

                          Seriously... let's ignore my inability understand that SDK for the moment.   Can you tell me what that means to an end user and what I can instruct them to do about it?

                           

                          They will copy and paste and simply drag and drop and jpeg into a container.   At that point it looks perfect.  But for some images in some situations the image will become just a jpeg icon when a script copies that image to another container.

                          • 10. Re: Containers, and Scripting, and Jpegs... oh my!
                            philmodjunk

                            Are you using the copy and paste script steps or set field to move the file from on container to another?

                            • 11. Re: Containers, and Scripting, and Jpegs... oh my!
                              user28271

                              I am using SET FIELD

                              • 12. Re: Containers, and Scripting, and Jpegs... oh my!
                                arjen.evertse

                                You could try to export the image from the Staff record and enter the global field using Insert Picture.

                                 

                                Something like:

                                 

                                Set Variable [ $path ; Value: Get(TemporaryPath) & GetContainerAttribute ( Staff::Signature ; "filename" ) ]

                                Export Field Contents [ Staff::Signature ; "$path" ]

                                 

                                Go to Layout [ Your Form ]

                                Go to Field [ Form::g_Signature ]

                                Insert Picture [ "$path" ]

                                 

                                The problem you have might be related to how the image was originally inserted in the Staff record. Insert File and Insert Picture do not behave the same on container fields in my experience.

                                • 13. Re: Containers, and Scripting, and Jpegs... oh my!
                                  siplus

                                  Why do you have to copy the signature in each and every record, bloating your table ?

                                   

                                  Just put the related signature on the layout, with a hide with condition that you toggle under certain circumstances.

                                  • 14. Re: Containers, and Scripting, and Jpegs... oh my!
                                    user28271

                                    Good point... but....

                                     

                                    The accounting dept require a signature on all document.  If I make that signature appear only as the related field then when that signature changes all the historical record will change too.  This happens often.  Someone get's married and therefore their name and signature changes.

                                     

                                    Open to suggestion.

                                    1 2 Previous Next