Hi y’all,
Am trying to use cloudant for syncing my database. Have followed the instruction re setting up an account, but I’m not sure where to find the password.
This is the alphabet soup I get from the “credentials” on the cloudant site:
{
“apikey”: “1ZQdMj162xdk3vf4N0ZMkQAhN4oikS2z5-xCd-SXAAIX”,
“iam_apikey_description”: “Auto generated apikey during resource-key operation for Instance – crn:v1:bluemix:public:cloudantnosqldb:eu-gb:a/6573add2f18f4d48b22620fd392dd094:32191e04-2a8b-4bbe-bc54-bff77190292f::”,
“iam_apikey_name”: “auto-generated-apikey-36ca775e-c28c-425c-bf55-4f5754841a8a”,
“iam_role_crn”: “crn:v1:bluemix:public:iam::::serviceRole:Manager”,
“iam_serviceid_crn”: “crn:v1:bluemix:public:iam-identity::a/6573add2f18f4d48b22620fd392dd094::serviceid:ServiceId-2432e2f3-f9ba-4cc1-be44-15a42d4bc426”,
“url”: “https://2dc42a4a-07a3-405f-91f6-66fbe35a4cdd-bluemix.cloudant.com”,
“username”: “2dc42a4a-07a3-405f-91f6-66fbe35a4cdd-bluemix”
}
The username is pretty apparent, but I have no idea what the password is. Can anyone help?
Many thanks in advance.
I created a mileage tracker form but posted it in the regular forum. Figured I should post it here for everyone to download. It requires Tap Forms 5.3 at a minimum because it uses JavaScript to copy the previous mileage value to a new record. You need to select a record and then run the script. Tap Forms will create a new record and copy over the values from the selected record to the new record.
Use the Import Tap Forms Archive function to import this file.
Thanks!
Brendan
Attachments:
You must be
logged in to view attached files.
Hi Brandon,
Cool! Didn’t think of that at all.
When I run it in the ‘edit script’ view, the result is shown in the Results field. I would expect to see this in the Title field in the Layout View too, but that remains empty.
Sorry for all the beginners questions!
Thanks!
– Daniel
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Yup. You’re right. I’ve just made a change to fix this so it will do what it’s supposed to do. The Mac version was just calling the wrong code that wasn’t evaluating the script only for those fields that were referenced in it. But the next update will behave that way.
Hi
I have the parent database “Photo Database” with the child “Photo Prints”. The child database is used to keep track of all prints created and sold. In there, I would like to include some basic information from the parent database such as image title.
In the parent database I set the one-to-many link and enabled show inverse relationship. Then in the child database I created a field with the type ‘script’ containing
var image_title = photo_database.getFieldValue('fld-a64a1b71aeb8408499143d9c852b0056');
image_title;
But when I run it, following error:
ReferenceError: Can't find variable: photo_database, column:33, line:1
I guess I’m missing something to define photo_database which is the parent “Photo Database”. Attached is the sample template. Thank you for your help!
– Daniel
Attachments:
You must be
logged in to view attached files.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
I’ve done a bit more investigating.
In the script editor (on the Mac) after saving and then reopening it, there is a check mark against the A field and none of the others. So the script is doing the clever bit (knowing that it should only run on changes to A), but it appears to run on changes to any field.
I’m using Tap Forms 5.3.2 on the Mac.
I’ve now just checked on my iPad and iPhone and the script, correctly, only updates on changes to A. So perhaps it is a bug in the Mac version?
Thank you for that. I think I’m starting to get it.
To help my understanding I wrote this field script:
var a = record.getFieldValue(a_id);
record.setFieldValue(time_changed_id, Date.now());
document.saveAllChanges();
As expected, when I change the value of a, the time in milliseconds is shown in the other field.
So I added two more fields (and didn’t change the script). When I click between the two new fields (not editing them), the time in milliseconds is still getting updated.
I guess I should be doing something else to ensure the script only runs when a is changed. Could you point me in the right direction?
Thanks again.
Hi Martin,
It’s because when you use the record.getFieldValue() call in a field script and click the Save button on the script, Tap Forms stores a list of field IDs that it references in that script separately on the Script field itself. Then when you change a value in one of those referenced fields, Tap Forms searches through all Script fields to see if that field being edited is referenced. If so, then it executes that script.
That’s how the example works. When you save the Script field, Tap Forms stores the ID of the barcode field being referenced. When you change the barcode value, Tap Forms finds the script that references that field and executes it. The code then fetches the JSON data from the URL specified along with the barcode value and then sets the other fields to contain the data parsed from the JSON response.
Hope that makes sense. It’s really quite a powerful feature.
Thanks!
Brendan
Thank you for that. That makes sense.
How does Tap Forms knows when any of the other fields the script references change?
eg. in the Tap Forms manual there is an example field script which fetches movie data when entering a value into a barcode field. How does Tap Forms know to only run this script when the bar code changes, as you wouldn’t want the api.upcitemdb.com call when the user changes another field.
Thanks
Martin
Field scripts are executed when any of the other fields the script references change.
So if you have a script that references a Checkmark field, then when you click the Checkmark in the form, the script that references that field should execute.
Same on iOS or Mac.
But you can trigger all the scripts to run in all of the records by clicking the Refresh button at the bottom of the records list view. On iOS you can pull down on the records list view to trigger all the Calculation and Script fields to execute.
Form scripts run only when you manually trigger them.
I want to run some JavaScript when a check box is checked on a record (I have a field script that checks the value of the checkbox, if checked it runs the main logic and then unsets the check box).
I was wondering how often a field script is run?
- On every update
- Every time the record in viewed
- On import
Also, does this vary between iOS and MacOS?
Thanks
Martin
Thank 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
Sure, 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 of form.getRecords(). Or you can ask the form for a specific with a provided name. E.g. var search = form.getSearchNamed('Action & Adventure'); Then do search.getRecords();.
Hi,
Thanks for all your help with the queries I’ve had regarding scripting on iOS.
I’ve found it quite hard to debug on iOS as I can’t see where the console.log() output goes. Is there somewhere I can view the console?
It works in on MacOS (but I rarely have access to my Mac so rely on iOS)
Thanks again,
Marrin
Actually the script does seem to be running, but a second call to alertWithMessage isn’t showing, nor is the final “success” dialog.
I will have to investigate further.