Jump to content

Web viewer Javascript making FMP URL call back to same file (not hosted, non-iOS)

Justin Close

This topic is 2798 days old. Please don't post here. Open a new topic instead.

Recommended Posts

In FMP 13.02 FileMaker apparently fixed the FMP URL for the desktop client, such that it could be used to make a call to the same/local/self file.  So I would have a web viewer in a solution and it would use an "fmp://web.address/dbname..." URL that would reference itself, the file that was currently open.

I found some references to how to do this, but for some reason things aren't working for me.  Apparently, if you are on a non-mobile platform, you need to use "$" as the IP address to reference the local file.  E.g. "fmp://web.address/dbname.fmp12?script=AScriptName&$var1=1234&$var2=abcd".  This would make the database essentially accept AJAX calls.  (Although an unanswered question for me is how does the response or data get back to the web viewer.  But for now, I just want to register event that trigger sending new data into the DB.)

Here's the code I am using for my web viewer definition.  The short description is that I am trying to integrate Full Calendar into a web viewer in a solution.  I am trying to configure the onDrag event so that when an event is modified it sends the new date range back to the DB.

Let ( [     _IPDestination = If ( Left(Get(FilePath);7) = "fmnet:/"; Get ( HostIPAddress ) ; "$" ) ;     _fmpURLString = "fmp://" & _IPDestination & "/" & Get(FileName) & ".fmp12" ;     _fmScript1 = "?script=FullCalendarChangeDate";     $CurrDate = "2015/7/01"         //hardcoding for testing purposes ]; "data:text/html, <!DOCTYPE html> <html><head><meta charset='utf-8' /> <link rel='stylesheet' type='text/css' href='http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.3.1/fullcalendar.min.css'/> <script src='http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js'></script> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src='http://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.3.1/fullcalendar.min.js'></script> <script>     $(document).ready(function() {         var   httpXHR, fmpurl ;         $('#calendar').fullCalendar({             defaultDate: '" & $CurrDate & "',             editable: true,             allDayDefault: true,             eventStartEditable: true,             eventDurationEditable: true,             dayClick: function() {                 alert('a day has been clicked!');             },             eventDrop: function(event, delta, revertFunc) {                 if (!confirm(event.title + ' was dropped on ' + event.start.format() + '.nAre you sure?')) {                     revertFunc();                 }             },             eventResize: function(event, delta, revertFunc) {                 if (!confirm(event.title + ' end is now ' + ( event.end.format() ) + '.nnIs this okay?')) {                     revertFunc();                 } else {                     fmpurl = '" & _fmpURLString & _fmScript1 & "&$eventid=' + event.id + '&$newEndDate=' + event.end ;                     httpXHR = new XMLHttpRequest();                                 httpXHR.open("GET", fmpurl, true);                 }             },             events:  [                 {                     id: 1,                     title: "Project 1",                     start: "7/1/2015",                     end: "7/3/2015"                 },                 {                     id: 2,                     title: "Project 2",                     start: "7/3/2015",                     end: "7/7/2015"                 },                 {                     id: 3,                     title: "Project 3",                     start: "7/7/2015",                     end: "7/7/2015"                 },                 {                     id: 4,                     title: "Project 4",                     start: "7/7/2015",                     end: "7/11/2015"                 },                 {                     id: 5,                     title: "Project 5",                     start: "7/14/2015",                     end: "7/16/2015"                 },                 {                     id: 6,                     title: "Project 6",                     start: "6/18/2015",                     end: "7/3/2015"                 },                 {                     id: 7,                     title: "Project 7",                     start: "7/30/2015",                     end: "8/15/2015"                 },                 {                     id: 15,                     title: "Project 15",                     start: "6/08/2015",                     end: "6/19/2015"                 }             ]         });             }); </script> <style>     body {         margin: 0;         padding: 0;         font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;         font-size: 14px;     }     #calendar {         width: 900px;         margin: 40px auto;     } </style></head> <body>     <div id='calendar'></div> </body> </html> " )


In the middle of that you will see these three lines, where I am trying to make that call back to the local file from the webviewer:

            fmpurl = '" & _fmpURLString & _fmScript1 & "&$eventid=' + event.id + '&$newEndDate=' + event.end ;
            httpXHR = new XMLHttpRequest();            
            httpXHR.open("GET", fmpurl, true);

Any one have experience achieving this?  Todd Geist's Watermark module uses this technique but I can't seem to extract that functionality for my own purposes here.  :)


-- Justin

Link to comment
Share on other sites

I heard back from Todd with some clarifications:

Apparently, you still can't use an XMLHTTPrequest directly to FM.  Some plugins may enable such functionality, but nothing natively handled at this time.

You can partially achieve this result (send-only, from webviewer to FM DB) via:  window.location = "http://a.url.com/database?script..."

Link to comment
Share on other sites

This topic is 2798 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.