11 Replies Latest reply on Feb 20, 2013 8:44 AM by bsheifer47

    How can I change the Lan ip address in a Script-Generated Snapshot link?


      I have a script that runs daily, that sends an email notifying FM clients that they have not followed up on something. Included in the email is a Snapshot Link to easily direct them to the record where action is required.


      All is well and good for clients on the LAN, but for those accessing the hosted file from the WAN, the Snapshot Link will not work. If I open the Snapshot Link with TextEdit, and change the LAN address to the WAN address and save it, all works fine and the client is prompted for a user name and password, and the correct record access occurs in the remotely hosted file.


      Below is the xml in the Snapshot Link showing where the LAN to hostname change was made:


      <?xml version="1.0" encoding="UTF-8"?>

      <FPSL><UIState><UniversalPathList>fmnet:/</UniversalPathList><Layout id="14"></Layout><View type="form"></View><SelectedRow type="nativeID" id="85"></SelectedRow><StatusToolbar visible="True"></StatusToolbar><Mode value="browseMode"></Mode><SortList Maintain="True" value="False"></SortList></UIState></FPSL>


      The Server is generating the emails (around 50 per day), and the .fmpsl file is placed in the server documents folder, [Get (DocumentsPath), and each successive record overwrites the .fmpsl with a new file with the applicable information about the record, which gets attached to the next email.


      Is there a way for the Snapshot Link to reference our external host address rather than the internal LAN IP?


      I tried saving the Snapshot Link to: [Get (DocumentsPath) & "myhost.com/sslink.fmpsl"], but since there is no myhost.com folder in the Server/Data/Documents folder, the .fmpsl does not get created or attached.

        • 1. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?



          No way of altering the FPSL file when it saves that I have ever heard of.


          Only way I can think is alter it after is generated. Have not tried this at all, but you might be able to use a plugin (that is certified and licensed to run on the FM server) that can open the file as text, alter the IP address info, and save. I am assuming that you know which clients are external vs. internal and that they don't change (i.e., one day that person is in the office and the next day they are outside the office). In your scripting that saves the FPSL, if client is external, call sub-script to change the text in the file.


          As for sub-folders inside the Documents folder, you can create them and then you should be able to save to them. Specifying a path like you show won't create them on the fly.





          • 2. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

            Sorry, AFAIK, not from within FMS. Since FMS is running the script it is looking at the local IP address. If this was done by a computer on the WAN that used the WAN IP to connect then it could be made to work. A DNS name also works. However, when run on FMS the only connection the script knows about is the Local IP.


            On a Mac you could use AppleScript to edit the IP string to the WAN DNS.

            On a Windows maybe use a .bat file to generate Command Line editing to do it.


            Main problem with either of these is getting the file ready before using it. Since everything is asynchronous you have to allow time for everything to complete and you don't really know the maximum time it could take.

            1 of 1 people found this helpful
            • 3. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

              The snapshot link can be opened in a text editor (FM11 at least, don't have an FM12 snapshot to try it with). The IP address is visibile there. I used BBEdit on the Mac.


              The snapshot file is an XML file. Theoretically you could create the contents as a calculated field and export it with the correct extension. There are a lot of additional things in the XML file beyond the IP address and file name. If you were to try it I'd create a snapshop in FM and see what's in there. It'd be very easy to mess things up. Especially since the links.


              What about exporting the file, using a plugin that would read the file for editing (360Works Scribe?), modify it and send out the modified version?

              • 4. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

                Thanks to you and BowdenData on my predicament.


                Interesting thing is, take my little Mac Mini which basically only has Filemaker Server installed, and plug it directly into the internet (without all the router/firewall benefits), it would only see the WAN address and probably work fine. However, in addition to security issues, I expect that would also make performance suffer on the LAN, which the Mac Mini would no longer be part of.

                • 5. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

                  My original post included the XML text of the snapshot link. If I could open that, do a search and replace and then close it back up again, that could possibly work. How does one do this in the midst of a Server-side script though.

                  • 6. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

                    again - just talking out loud here....


                    Is the server side script an execute once every night type of thing? If so, what about the following workflow. The times are just examples.



                    Server task is set up as a Script Sequence. Runs at 8:00pm.


                    1) Runs an OS level "before" script. The OS script deletes all the FPSL files in the Server Documents folder.

                    2) FM script runs. The FM script is one big one that has two parts to it or is a wrapper script that calls sub-scripts.

                    In "part 1" of the FM script, it finds all the client recs that are LAN based, does its thing, generates the FPSL files in the Server Documents folder, and mails them out. Basically, just what your script does now. By using the default name of the FPSL file, each one overwrites the existing one as you loop through things.

                    In "part 2" of the FM script, it finds all client recs that are WAN based. Loop through client recs, and generates the FPSL file to the Documents folder. Instead of a default name though, you name each file with something like a client ID. Basically some mechanism to make each filename unique and identifiable as to belonging to a specific client. This is so they won't overwrite each other.

                    3) Runs the OS level "after" script. This script loops through all the files in the Documents folder that are FPSL type. For each one, it opens them up for editing, replaces the LAN address with the WAN address, and closes them.


                    Another Server task is set to run at 9:00pm.


                    This is a regular FM script type task.

                    The FM script uses the built-in Get (DocumentsPathListing) function to gather a list of all files in the Server Documents folder.

                    Loop through the list of files. Since each filename will contain an identifier that you can link back to a client rec, you can grab the email address for that client, build a variable pointing to the FPSL file you are working on, and then send that file out as an email attachment.


                    To not rely completely on there being enough time between 8pm and 9pm for the first task to finish, you could have the "after" OS level script create a file in the Documents directory that would be named something like "emailready_20120212.txt". You wouldn't need anything in the file. Then when the 9pm task runs and reads the Documents folder listing, you can check for the existence of this file in the list. If it is not there, then abort.


                    As ch0c0halic noted, the OS scripts could be done in AppleScript since you say your FM server is on a Mac. I don't know Applescripting much at all, so you would need to figure this part out or find/pay someone to write it for you.


                    I may have missed something or my workflow could be improved, but am pretty confident that this can be made to work.





                    • 7. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?



                      Interesting approach.


                      I find the Snapshot Link so helpful, and am surprised Filemaker has not provided some way to fully utilize when not on a LAN. It would then work on an iPad or iPhone without having to first log on with FM Go.


                      I don't know AppleScript either. Many times over the years I thought I would learn, but never seemed to have enough of a need.


                      Another issue is I really don't know who needs to access from the LAN or from the WAN. The setup where the solution is used is simplistic enough that it doesn't require a VPN, Citrix or Terminal Server, all of which in previous cases basically provide LAN access once you are logged in.


                      After placing the original post, I began playing around with just creating a link in the Server-side email message, which seems to be "clickable" in most browsers. I came across the following Filemaker article:


                      Opening shared databases remotely using a URL: http://www.filemaker.com/12help/html/sharing_data.16.7.html#1029797,  and it enables you to log on remotely and run a script. Not perfect but probably easier than hacking into the Snapshot Link and altering.


                      Thank you for brainstorming this with me.



                      • 8. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?



                        Doh! I know the new URL functionality in 12 as I have used it before, but didn't think of it in your context. I was fixed on ways to make the snapshot link work. Given the constraint of not knowing which end user would be on the LAN vs. the WAN, the URL approach sounds like the best idea. As you will have read, you can include a script to run, parameters, and variables in the URL. This should allow you to somewhat mimic the functionality you get with a Snapshot link.


                        PS - A behavior that I did not see documented with FMP URL's that contain a script to run and variables, is that they are self-defining. Using the example in the Help of:




                        When the script ListClients runs, the variable $NumberToList will automatically be defined (and have value of 10) without you needing to do anything. Pretty cool, I thought.





                        • 9. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

                          I thought so, and thank you for your additional input on URL's. I defined a variable that contained the pk of the record I wanted to access, and a short script to access the record via relationship. The only issue with the URL vs the Snapshot, is I can't control how the URL will show up on the various users' browsers. It is clickable (or touchable) on a Mac, iPad or iPhone, but on one version of Outlook I tried, it showed up as text.


                          Sent from iPad

                          • 10. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?

                            Try enclosing the URL string (that ends up in the email) with <>. Example: <fmp://string>.  This is an old trick that would sometimes coax Outlook on Windows to recognize it as a link. No idea about Outlook for Mac. If this does help with Outlook, hopefully, it doesn't break on the other apps that work now.





                            • 11. Re: How can I change the Lan ip address in a Script-Generated Snapshot link?



                              Thanks, just saw this reply going through some unread stuff. I will try. So far the link works on everything except Outlook 2010 (Win).