Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
March 22, 2022 at 8:10 AM #47027
In reply to: Help with a script
Stig Widell
ParticipantSam The problem is not the non parity.
The problem is that fader-ID is not shown after running the script Kalva.March 21, 2022 at 1:17 PM #47022In reply to: Help with a script
Stig Widell
ParticipantThe message “Script is run complete” I received in IOS.
When running in Mac I received “Fel! Sätta grupprekordet”March 21, 2022 at 1:08 PM #47020In reply to: Help with a script
Stig Widell
ParticipantHi again,
The script Kalva, created by Sam Moffatt, worked very well a couple of weeks ago.
Now when I have to use it because calves are started coming the calfs father in the form Kalvningar is not shown.
I get “Script is run complete” instead of “Gjord”
Enclose template.
Sorry about this.
StigAttachments:
You must be logged in to view attached files.March 19, 2022 at 2:06 PM #47014In reply to: Wrong values when accessing Date object
Daniel Leu
ParticipantJavascript date handling is a bit confusing:
The
getDay()method returns the day of the week for the specified date according to local time, where 0 represents Sunday.The
getMonth()method returns the month in the specified date according to local time, as a zero-based value (where zero indicates the first month of the year).What you want to use is something like this:
var drDay = sessionDate.getDate(); var drMonth = sessionDate.getMonth() + 1; var drYear = sessionDate.getFullYear();-
This reply was modified 4 years, 1 month ago by
Daniel Leu.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksMarch 19, 2022 at 1:44 AM #47004In reply to: Script to Add File Alias?
Ricard Casals
ParticipantBrendan, I reviewed the script I had and the file’s url and now everything works! – Something a small thing that wasn’t ok: a space in the url?, not enabled TF5 script folder preference? I have to be very careful about these little details in the code and the data it carries!
Thanks again for your patience and dedication!
By the way, the last line “document.saveAllChanges ();” is equivalent to “form.saveAllChanges ();”?
RicardMarch 18, 2022 at 10:43 PM #46996In reply to: Field Default Value Inherited from Previous Record?
Brendan
KeymasterHi Gary,
Yes there is.
What you want to do is make a Form Script that you run at the time you select the previous record and have the script make the new record for you and then copy all the values over to the new record from the selected record and then have Tap Forms select the new record.
On the Template Exchange forum there’s a Mileage Tracker form I posted which does exactly this.
So basically you’re defining what the previous record is by first selecting it. Then when the script runs, it gets that data and copies it to the new record. Now you can modify the new record any way you like. You don’t need to first make a new record by clicking the + button. Just select the old record and run the script.
Hope that makes sense.
Thanks,
Brendan
-
This reply was modified 4 years, 1 month ago by
Brendan.
March 18, 2022 at 10:39 PM #46995In reply to: Script to Add File Alias?
Brendan
KeymasterSo Daniel emailed me about this thread. Sorry I missed it before.
At first I thought, damn, my code isn’t working.
But then when I dug into it more, it turns out it is working.
There are a couple of things you need to do though.
1. Make sure the source files you want to make aliases for are accessible to the Scripting engine by setting the Script Folder on the Preferences window. Without this, Tap Forms won’t be able to read the file for it to make a bookmark/alias for.
2. Make sure you URL encode the URL string you’re trying to make an alias for. The only problem with this is you’ll get the encoding in the filename on the File Attachments field.
I’ve just added code to URL encode the provided URL and that avoids that problem. But either will work then.
Here’s a sample that worked for me in the existing version:
function Add_Alias() { var file_attachment_id = 'fld-36eea6e880d14959b2e002b8f9b060b8'; var url = "file:///Users/brendan/Desktop/All%20Wines.csv"; record.addFileFromUrlToField(url, file_attachment_id, {"alias" : true}); document.saveAllChanges(); } Add_Alias();and when I release the next update, this will work:
function Add_Alias() { var file_attachment_id = 'fld-36eea6e880d14959b2e002b8f9b060b8'; var url = "file:///Users/brendan/Desktop/All Wines.csv"; record.addFileFromUrlToField(url, file_attachment_id, {"alias" : true}); document.saveAllChanges(); } Add_Alias();Only the
All Wines.csvfile is different. But if your files don’t have any spaces or special characters in them, then you should be fine as is.Thanks,
Brendan
March 15, 2022 at 11:07 PM #46988In reply to: Script on a Field
Daniel Leu
ParticipantI added a dummy
var number = record.getFieldValue(field2_id);and now the field script gets executed upon a value change.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksMarch 15, 2022 at 9:33 PM #46987In reply to: Script on a Field
Bernie McGuire
ParticipantMy script.
function Total1() {var field2_id = ‘fld-1e5045dd497f4359a0a98b5bbc010059’;
var total = form.getTotalOfField(field2_id);
var total2_id = ‘fld-737e46579abc42b0a42dafb6f06b0bf8’;
record.setFieldValue(total2_id,total);;
form.saveAllChanges();
document.saveAllChanges();
return total;}
Total1();
March 15, 2022 at 9:26 PM #46986In reply to: Script on a Field
Daniel Leu
ParticipantMaybe sharing your script?
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksMarch 15, 2022 at 8:00 PM #46984In reply to: Script on a Field
Daniel Leu
ParticipantIt looks like your script is not triggered. This might be due to using
field.getId(). I would try this: in the script editor, click on the icon between ‘fx’ and ‘ABC’, selectfield_id, then click on your variable. This will provide you with the id definition that Tf uses to determine when to trigger a field script.Hope this helps!
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksMarch 15, 2022 at 5:52 PM #46983Topic: Script on a Field
in forum Script TalkBernie McGuire
ParticipantHello All. Im new to Tap Forms but am an experienced software developer. I can not get a script attached to a fied to execute. I put the same script at the form level and it executes perfectly when I click ‘run script’ Im using iOS on iPhone 13 latest OS and V5 of Tap Forms
Simple Form
Field1 Text
Fiedl2 number
Total1 -Script field
Total2 Number (to hold the calculated total)I have the script attached to Total1.
Basically gets the Field ID of Field2 (using the getID from the field list dialogue), does a var total = form.getTotalAllFields(field2_id) ,
does, setFieldValud(total2_id,total), I have both form.saveAllChanges and document.saveAllChanges. I also return total from the function.
As I mention this script runs perfect from the form object.I know there is a simple answer but I can not figure it out. I have tried all the suggestions I have found but none are working for me.
Thanks for any help.March 10, 2022 at 8:57 AM #46977In reply to: Script to Add File Alias?
Ricard Casals
ParticipantDaniel, yes, you’re right, this script is too inelegant and ineffective to be useful to anyone but me. I’ve shown it almost as a curiosity while we wait for the right way to do it.
Other than that, thanks again!
March 10, 2022 at 8:46 AM #46976In reply to: Script to Add File Alias?
Daniel Leu
ParticipantWow, this is scary….
>click button 4 of UI element 2 of row 4 of table 1 of scroll area 2 of splitter group 1 of splitter group 1 of window 1
>click text field 1 of UI element 1 of row 2 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of sheet 1 of window 1
>click button 3 of sheet 1 of window 1I would not want to maintain this, at least with your comments it is a bit easier! It is great that you have found a way to automate attaching a file as an alias.
Once the
record.addFileFromUrlToField()issue is fixed, you can call the Tapforms’ script interface usingtapformz://script/db-xxxx/frm-xxxx/Test+Script?option1=A&option2=B.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksMarch 10, 2022 at 3:57 AM #46975In reply to: Script to Add File Alias?
Ricard Casals
ParticipantThis is a very simple (and primitiv?) Applescript to attempt to add a single photo alias to a ‘File Attachment’ field on a single record.
The next step will be an automated ‘repeat with’ from a list of photos to a bunch of records in Tap Forms.
Waiting for a better and cleaner solution with an script in Tap Forms.
With this code, it works to assign a single alias to a single field. It’s a small thing, yes, just to keep going and learning!
-- 220310B - 'TF_AS3' (WIP)
-- NOTE: the 'POSIX file' depends on your own photo folder path.
-- NOTE: the value of 'row 4' (in the first 'click button' line) depens on the 'File Attachment' field position.
-- NOTE: the parameters of 'click text field…' line and 'click button 3 of sheet…' depends on the own photos path, obviously.
set f to POSIX file "/Users/ricardcasalsalexandri/Desktop/fotos-test-2/19770101.JPG"
set sourceFile to f
tell application "Finder"
activate application "Tap Forms 5"
tell application "System Events" to tell process "Tap Forms 5"
click button 4 of UI element 2 of row 4 of table 1 of scroll area 2 of splitter group 1 of splitter group 1 of window 1
click text field 1 of UI element 1 of row 2 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of sheet 1 of window 1
click button 3 of sheet 1 of window 1
end tell
end tell
(I tried to attach the script – also as a zip – but I can’t figure it out)
-
This reply was modified 4 years, 1 month ago by
-
AuthorSearch Results