Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Can't script a record update on iPad
Tagged: Scripting
- This topic has 5 replies, 2 voices, and was last updated 6 years, 1 month ago by Martin Kendall.
-
AuthorPosts
-
October 7, 2018 at 6:24 AM #30938
Martin KendallParticipantI have a test script that updates a record on MacOS Tap Forms, but it doesn’t update the record on my iPad.
Here is an example:
var field_id = ‘fld-43e292a99a1646f1b5574954169ab319’;
record.setFieldValue(field_id, ‘Martin’);
document.saveAllChanges();Could you please point me in the right direction to get this working on my iPad (works great on MacOS).
The database was created on the Mac and shared to the iPad, then synchronised with Nearby Sync.
Also, does the concept of current record exist in iPhone scripts?
October 7, 2018 at 6:32 AM #30939
Martin KendallParticipantI’ve just worked out what the issue is.
On the iPad the record that I’m updating is the first on the list, not the currently selected one.
How do I get the current record, not the first one?
Thanks
October 7, 2018 at 5:27 PM #30942
BrendanKeymasterHi Martin,
Is this a form script or a Script field?
If it’s a Script field, then
record
should refer to the current record.If it’s a form script, then you’ll need to find the record you want to update within the script by searching for the right record by looping through them.
October 7, 2018 at 11:23 PM #30947
Martin KendallParticipantGood question about whether it is a form script or field script. It’s a form script (would updating a record in a field script make sense?)
I don’t want to loop through and find the record as I am scraping a website (for missing image data) and don’t want to run though all 1000 records and hit the website. On the Mac I was relying on the current record, I guess I can’t do that on iOS.
I will add an extra check box that I will set manually before running the script and then the script can search on that.
October 7, 2018 at 11:32 PM #30952
BrendanKeymasterSure, you could update a record in a Field Script. An example of that might be selecting something from a Pick List that triggers a script to run and it updates a different field in that same record.
You could also have a Saved Search that fetches the records you want to update and run the script just on those records. You would use
search.getRecords()
instead ofform.getRecords()
. Or you can ask the form for a specific with a provided name. E.g.var search = form.getSearchNamed('Action & Adventure');
Then dosearch.getRecords();
.October 8, 2018 at 2:51 AM #30955
Martin KendallParticipantThank you for all your help.
The solution I have gone with is to have a field script that updates the record (from the webscrape). I have also added a check mark to say when I want it to run.
The field script checks the value of the check mark and if set, it runs the web scrape, updates the fields and then unchecked the checkmark.
Thank you
-
AuthorPosts
You must be logged in to reply to this topic.