Thanks! That is a great starting point. I am trying to figure out how to then calculate the total number of each item ordered and subtract that from a quantity of the items received… Not sure if a script would be needed or if I am missing something obvious…
The Location field value is just a dictionary. So you need to make a new dictionary object in JavaScript before you set the values on it. Essentially you’re getting a null value back from getFieldValue(). If you get a null value, then you just create an empty dictionary and then your code should work.
var location = {};
I have a suble script problem:
I want to create an artificial location field value.
I wrote this little script:
function SetCoordinates() {
// Durch eigenen Code ersetzen
var coord_id = 'fld-65d2a762b14542f9abbca1d521df2e37';
var title_id = 'fld-692eb15910f7433181f8f8a6b2fceccc';
var gps_lon_id = 'fld-4a453e4f44854f0f893d3e275d4342c4';
var gps_lat_id = 'fld-4dfd053afaec40b58395083e694085ac';
var location_value = record.getFieldValue(coord_id);
location_value["title"]= "GST " + record.getFieldValue(title_id);
location_value["lon"]=record.getFieldValue(gps_lon_id);
location_value["lat"]=record.getFieldValue(gps_lat_id);
record.setFieldValue(coord_id, location_value);
}
SetCoordinates();
If the field coord_id has already a value this works.
If it has no value (such es no one pressed the location icon before) this doesn’t work. How can I create an empty data structure of the type location?
Thanks for hints
This script:
var t = form.getFieldNamed(‘P1’);
console.log(t.name);
console.log(t.fieldType);
console.log(t.fieldDescription);
console.log(‘eoj’);
This is the console panel
undefined
undefined
undefined
eoj
In the Form there is a P1 field.
What’s wrong?
Thanks.
Can you add a property field_id?
For make indipendent scripts From Forms, and indipendent by database, i need a function like this:
Form.getfieldid(‘name Of field’);
And return the field_id ‘fld…’ without open snippets.
Gianantonio
Thanks.
Can you add a property field_id?
For make indipendent scripts From Forms, and indipendent by database, i need a function like this:
Form.getfieldid(‘name Of field’);
And return the field_id ‘fld…’ without open snippets.
Gianantonio
There’s no scripting support for adding to the Calendar.
The very first field in your form is what’s used to generate the default Title value. You can edit the title value of course before clicking the Add to Calendar button. The link to the record is also added to the calendar.
Hi Gianantonio,
Right now the only things exposed are the name, fieldType, and fieldDescription properties.
I updated the JavaScript API to document the new APIs I added:
https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api
I just wanted to register another request for custom layouts in iOS.
I’m getting by for my use case by creating scripts to summarise information, which is a fantastic ability, but it’s a bit fiddly and not for everyone.
I do love the scripting, though.
How can I automatically enter my desired fields in the calendar?
And can an appointment also be automatically entered in the calendar?
Can I use a script for this? If so which code? Does anyone have any idea?
Please can you tell me the tffield’s struct?
Thanks
Gianantonio
Hi Victor,
The next update will support letting you reference another Script field within a script.
Thanks,
Brendan
Brendan,
In this post you showed how it is possible to use fields from a related Form.
I am adapting the JavaScript code in other fields.
But when I am in Edit Script, the list of fields of all Forms do not show any fields which are Script fields – so I cannot access them to declare their IDs.
Is there a way to do so?
I think I’m going to have to rethink how that deviceName property works. As you edit the records, the device name is stored on the record that edited it. But the script field also needs to be updated to show the deviceName value. And that causes a save to the database, which of course updates the database. I think I’m going to have to perhaps add something to the Script field that prevents it from updating the database, but to merely display the results. So maybe for now this is not going to work for you. Especially since if anyone else were to cause a Calculation field or a Script field to refresh across all records, they would effectively be updating every record, causing the deviceName property to be changed to their name.
Tap Forms was never designed to be a multi-user database system and this was just a bit of a hack to see if I could display the name of the device that last made an edit to the record. It clearly needs some more thought and work.
Sorry for getting your hopes up that this would be a viable solution.
Hi Stephen,
Yes, that’s right. Or you can just use this script:
function Device() {
return record.deviceName;
}
Device();
Try clicking the Refresh button at the bottom of the records list. You should see the value appear.
Thanks,
Brendan