Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › location field + getFieldValue returns undefined
- This topic has 4 replies, 3 voices, and was last updated 1 week ago by
Hans.
-
AuthorPosts
-
March 25, 2025 at 7:11 AM #51733
HansParticipantDear forum participants.
Briefly about me, my question (problem) below.
For over 8 years, I have managed my data with a NINOX -DB. I have tested Tap Forms sporadically, but I would rather not try the scripts. Well, from today’s perspective, a mistake ;-)
Finally, I found my way to Tap Forms, and I am very enthusiastic because Tap Forms offers everything I had before, and it is even easier and much more stable than NINOX. And I also get along well with JavaScript so far.
My DB is used:
- POIs (Point of Interests) for hiking, biking, and photography
- Tracks and routes: Record tour data (places, countries), types (MTB, hiking), difficulty (S0, S1, …), duration of a tour, with breaks, etc., weather data, and much more.
To my question, for which I need your support:
Goal: I would like to place the content from two different fields in a third field:
1)) Source: “Name of the location”
2)) Source: “Address of the location”
3)) Target: (“Name of the location”, “Address of the location”)However, with a simple console query, I only get the error message “undefined”.
Script:
function Addresse_mit_Name() { // field: address of the POI // 1st row: street, ZIP, city // 2nd row: lat & lon (GPS) // var adresse_des_poi = record.getFieldValue('fld-2a75296d19a64123ba33be5a6e5808ba'); // check values of field console.log(adresse_des_poi); // return of combined values return(adresse_des_poi); } Addresse_mit_Name();
Question:
What do I have to do to get the address from the location field, which I can then process as a variable?
Source field:
1)) Address
Type “location”
Name: “Address of the POI”
field-ID: ‘fld-2a75296d19a64123ba33be5a6e5808ba’Many thanks in advance for your support.
Best regards, Hans
March 25, 2025 at 10:31 PM #51734
BrendanKeymasterHi Hans,
I’m a mountain biker too! Great to see another mountain biker using Tap Forms!
For a Location field type, you’ll get a dictionary that contains keys and values.
But you should’t get
undefined
unless there’s no value stored in your location field for the currently selected record.Try using
JSON.stringify(location)
to see the dictionary:function Get_Location() { var location_id = 'fld-edb6afab4b0841dd948ef39fe2fbf637'; var location = record.getFieldValue(location_id); console.log(JSON.stringify(location)); } Get_Location();
March 26, 2025 at 1:35 AM #51735
HansParticipantThank you for your prompt feedback. Yes, the field was unfortunately empty, and now I get the values. It was for sure a beginner’s mistake.
Now I have the values:
{ altitude = “yyy.xxxxxxxxxx”; heading = “z”; lat = “45.xxxxxx”; lon = “12.xxxxxx”; pitch = 0; title = “street, ZIP city region, country”; }
Now I know that this is the output of a dictionary, which contains keys (e.g., “title”, “lon” …) and values (e.g., 45.xxxxxx).
Question: What do I have to do now to get the value from the key “title”, for example?
The suggestions here in the forum or on “stack overflow” have only produced errors within the script, and unfortunately, I don’t understand why – maybe because I am a beginner ;-).
If I get this solved, I have the form of “POIs” ready and can then develop all the other forms further, as I have similar queries here.
Many thanks in advance.
Best Regards, Hans
March 26, 2025 at 1:06 PM #51737
Daniel LeuParticipantEither
location.title
orlocation['title']
should work.March 26, 2025 at 2:49 PM #51739 -
AuthorPosts
You must be logged in to reply to this topic.