I have a calendar in a web viewer built using HTML, CSS, and Javascript. Using javascript, I have made it so if you click on an event in the calendar, the event's ID is copied to the clipboard. Then I want to be able to Paste that ID in a field using the Paste script step. On FileMaker Pro this works exactly how I want it to. But on WebDirect, this doesn't work.
On WebDirect, I can click on an event in the web viewer and it successfully copies the event ID to the clipboard. I can confirm this is the case, because I can manually paste the ID from the clipboard into a field on the layout. However, using the Paste script step, nothing is pasted. Upon further investigation, I have found that WebDirect appears to have its own clipboard for each script.
To test, I copied an event ID onto the clipboard, let's say the ID is 1. I then type A in a field. I ran a script that copies the contents of the field, sets the field to blank, then pastes from the clipboard. This copies A, clears the field, then pastes A. But when the script is completed, the event ID is still on the clipboard, and I can manually paste it into the field.
Why is this? Am I doing something wrong? Is there a way other than Paste (or manually pasting) to get something from the clipboard into FileMaker?
This is occurring on a Mac 10.14. The server, and FM itself are 18.0.3. And the browser is Chrome 79.
Sorry, I've just had a look at that. It will only work within FileMaker client. The calendar uses javaScript to call "fmp://" urls pointing at scripts. It's very cool but it won't work in WebDirect.
Are you able to use your browser console to debug the webDirect buttons? You may be able to emulate those calls in your javaScript? I haven't ever tried to do this, I'm only thinking out loud.
I believe that Otmar's got these sorts of things figured out (including with WebDirect), about as well as anybody, and hopefully can chime in with the currently favored approaches.
It sounds as though the overall goal here is a WebDirect-compatible way to have FMP-proper receive data from the WebViewer. Using the clipboard is a very clever approach. I'm not really surprised that it does not work in WebDirect, and I question its robustness, but even so, I truly admire the mind that thought of that and gave it a try.
Most (if not all) of the solutions that I have seen that allow a WebDirect webviewer to push data back into the system relied upon opening up an API (e.g. Data API, XML API) and having the webviewer use an HTTP request to push data back into the system via the API.
Another approach that I once used was to run a PHP server (sans any API), and have the webviewer store snippets of data in a PHP session. These same snippets of data could then be retrieved by FMP by making a request to the PHP server via Insert From URL. The details involved the webviewer and the FMP session that it belonged to sharing a PHP session ID, so that they both had their own "space" where they could pass data back and forth. Different FMP sessions would have different PHP session IDs (so that there would be no collisions between sessions).
I haven't looked at this topic for a while, however, so I am hoping that Otmar can clue us in on what currently works best, and with the least amount of setup.
Since the migration to the new community platform I lost ownership of the document there, so I can't do any updates. Get my latest files here: Resource Calendar | balimusic
Yes my ResourceCalendar is using the fmp(XX)-protocol for FMP and FMGo, for webdirect it's either using cwp/php or the data api (V4Rest-versions) to write a callback-record with a session id into the Tasks-table. A timer script is watching this table and running the the callback script. This is working quite reliable, not as instant as in fmp/fmgo but close to. @PattyB, if you need support with the integration, don't hesitate to ask...
best
Otmar
P.S. for the cwp/php there's no need of setting up a separate web server, just use FMS's one. My latest version includes some helper scripts to publish the sources direct using PSOS.