I would try getting rid of the copy and paste lines. Copy and paste is prone to issues on a desktop, and clears any clipboard contents that the user may be needing on another application. On an iOS device, it may have any even greater negative impace and/or not work as intended. A far better and more stable methode is the Set Variable & Set Field script steps.
try changing the script to the followig and see how you get on.
Set Variable [ $Title ; Value:Visits Template::Title]
Enter Find Mode [ ]
Set Field [VIsits Template::Visit Date; Month(Get(CurrentDate)) -1 & “/“ & Year(Get(CurrentDate))]
Set Field [Visits Template:Title ; $Title]
Perform Find [ ]
Sort Records [Restore: No dialog]
Go to Record/Request/Page [Last]
Set Zoom Level [150%]
Perhaps you use a different layout for your iOS devices. As the previous post points out, there are potential problems with copy and paste--in this particular case, maybe the desktop layout has these fields and the iOS layout does not. That would keep the copy/paste from working in your script when run on your iPad.
Set Variable/Set field instead of copy/paste is the correct way to go here as those steps only require the correct table occurrence context and do not require that fields be physically present on the layout.
Thanks for your reply. Having a little trouble getting your Script to work, after first getting it to work, but looking in to it more.
Do you have Advanced version of FileMaker? If so, try using the script debugger and dataviewer to ssee that $Title variable is being set correctly and that the Field 'Title' is being set correctly with the contents of the variable we had just set.
You say that you fire the script while in List View. Are you sure that the button which calls the script is within the main body of the layout?
Looking again at the script I provided, I cannot fathom any reason why it would not work without seeing your file in more detail.
As an aside, in the original script that you posted, you had entered Find Mode, set a date feild and then did a sort and then goto last, then pasted the clipboard into another field and only then run the search.
Was there any reason why your sorted when you did, was there anything else going on in the script?
I don't have F.P. Advanced. Just F.P.12. The button is in the Header, which always worked from the Desktop the way I had it written before. I'm not sure why I wrote the script the way I did several years ago, but it worked. I only needed to run it from the Desktop to help with a monthly invoice, and it always worked fine from there. I tried to do the invoice last weekend while out of town with my iPad only, but noticed it wasn't working anymore (if ever?) from FileMaker Go 15. Could be using more recent versions of Filemaker Go started the problem, compared to when I first created it.
Below is the Script (printed out from FileMaker), and a screen shot of how the script "returns" now.
Note that "Value:Visits Template::Title" is in the "Title" field (for Patient Name), rather than the individual patient's name I had selected.
(Purpose of the script is to, after manually selecting a patient's record, to run the script to "Find" how many times they were seen in the prior month from the current mo.. I cross check this # with my work's Medical software record of visits, and then create the invoice from within FileMaker. (I'm a Contractor.)
Show Selected Pt's Visits for Prior Month
Set Variable [ $Title; Value:"Value:Visits Template::Title" ]
Enter Find Mode [ ]
Set Field [ Visits Template::Visit Date; Month(Get(CurrentDate))-1 & "/" & Year(Get(CurrentDate)) ] Set Field [ Visits Template::Title; $Title ]
Perform Find [ ]
Sort Records [ Keep records in sorted order; Specified Sort Order: Visits Template::Visit Date; ascending Visits Template::Visit Number One Month Only; ascending ]
[ Restore; No dialog ]
Go to Record/Request/Page
[ Last ]
Set Zoom Level
[ 150% ]
Thanks again for looking at this.
Ok, thanks for the screenshot...that helps tremendously and I can see where the problem is occuring.
You have set the value to be "Value:Value Visits Template:Title" - The Qoutation marks "" are making FileMaker put that exact text as the variable, and not the content of a field.
So, to fix, go back into editing the script and click the gear icon on the Set Variable script step.
Firstly lets clarify which field you want to be searching (Title, patent name, other?) Whatever the actual field, for the sake of clarity let us call it FIELDA (obiously replacing any instance if FIELDA in my example with your actual field name).
Then, on the value line, click 'Specifiy', take out everything that is in there at present and then double click the name of the required field from the left hand side listing. (FIELDA) but also make sure that the top left drop down TO is correct (Visits Template ?). Press Ok
Then, on the "Set Field" section, change the second set field to be: Visits Template::FIELDA; $Title then save the script. It should now work.
That did the trick. Thanks a million!!
I've been using F.P. since version 2, mostly for my own personal use, but haven't been keeping up with all of the Script lauguage. I've never used the "Set Field" Script step until now. I'll have to read up more on that and see how it's used. It makes sense that Copy-Paste could cause problems, especially in iOS.
Script steps with the first word "Insert"
are all inherently "brittle" script steps. Future layout changes can affect scripts that use these steps and no error messages automatically pop up to tell you that your original script is no longer working correctly unless you have put an explicit check for an error code immediately after the step.
Require that any specified field be physically present on the layout. Remove the field in a future layout update and the script fails.
Put the focus into the specified target field. This can trip OnObjectEnter on the target field. It can also trip OnObjectExit, OnObjectSave and OnObjectValidate on some other layout object that just lost the focus due to the execution of this step. Note that this could cause an intermittent failure due to a different object having the focus at different times when your script is run. Note also that just adding a script trigger, possibly to some other object on your layout can be enough change to introduce a problem for the original script.
Copy then adds the additional negative effect in that it replaces any data copied by the user with data copied by the script step. A user copies data for some other purpose, runs your script, then pastes only to paste completely different data than what they expected. This confuses and irritates users and should be avoided if at all possible.
Thus, all of these steps should be avoided if possible. Some steps are easier to avoid than others as some, such as those that insert files/pictures into container fields which do not have readily available alternatives. Others, like Insert Current Date can pretty much be avoided for all but an extremely small number of use cases.