Search Results for 'script'
-
Search Results
-
I have been very impressed with how easy it was to import several thousand records from a previous database into Tap Forms 5. Adding pick lists, calculation fields and the like worked so well. There is one aspect I need advice on.
The way I previously stored records of training completed by each person is one I need to change. (The previous TRAINING records only carried a course code and a person code.) So far I have managed to write a script that extracts the course codes for each person from a one-to-one linked field (“TRAINING”). Now what I want to do it insert these codes (“course_code”) into another many-to-many linked field (“TRAININGnew”) and I don’t know how to script this.
Manually it works. I go to TRAININGnew, click on the little tick at the bottom that prompts “Select existing linked records”, I click on the course code from the linked form COURSES and the relevant course code and details appear in TRAININGnew. I need the script equivalent of this action. So my question is, how do I script this so that it will use the course_code extracted from TRAINING and select an existing course record identified by this course code in the TRAININGnew link so that the full course details will appear in the TRAININGnew link.
Many thanks
Brian Lennon
Topic: Convert 2 fields
I have 2 fields “feet” and “meters” which relate to the elevation of a location of a record.
I often have feet, or meters but not both. I want a script (I assume to put in the “Script” tab of that form to check if a record has one of the fields not empty, then to convert to the other field. If both fields are not empty, leave it alone.
I asked ChatGPT and it gave me this to do a simple conversion to see if I could get started and I pasted in between the Function Names.
My first stumble was I couldn’t find the command in the directory of Script commands in the first statement “form.getSelectedRecords()[0]”. Do I insert something in the ()? I asked in the other forum, but couldn’t get any script help there. I think I understand how to put in the “sourceField” and the “targetField”.
function Convert_Elev() {
// Get the current record
var record = form.getSelectedRecords()[0];// Replace “sourceField” and “targetField” with the actual field names in your form
var sourceValue = record.getFieldValue(“sourceField”);// Perform the conversion (e.g., convert from inches to centimeters)
var conversionFactor = 2.54; // 1 foot = 0.3048 meters
var targetValue = sourceValue * conversionFactor;// Update the “targetField” with the result
record.setFieldValue(“targetField”, targetValue);// Save the record to apply the changes
record.save();}
Convert_Elev();
Convert_Elev() {
// Get the current record
var record = form.getSelectedRecords()[0];// Replace “sourceField” and “targetField” with the actual field names in your form
var sourceValue = record.getFieldValue(“sourceField”);// Perform the conversion (e.g., convert from inches to centimeters)
var conversionFactor = 2.54; // 1 foot = 0.3048 meters
var targetValue = sourceValue * conversionFactor;// Update the “targetField” with the result
record.setFieldValue(“targetField”, targetValue);// Save the record to apply the changes
record.save();}
Convert_Elev();
Topic: testing scripts
I want to test a script, but not in my original form.
How do I make a copy of my form with just a few or all of the records so I can test something?
I’ve tried saving an archive of the form and changing the name on it and importing it, but it just disappears – were the empty records imported into the current form from which it came???
I’ve tried making a copy of the form, but that form is empty. How do I get some data into the copy form without making up stupid data with a lot of work?
What is the best procedure here?
Hi,
I have a neat POI form that tracks all of my favorite destinations and uses JavaScript to calculate their distance from my current location. (It sorts by Distance, making it easy to see which places are nearby.)
I created a POI record called Current Location which I manually update each time I travel. Each other POI calculates the distance away from that Current Location POI.
I was wondering if there is anyway to automatically update the Location field of my Current Location record. I have googled a bit and see mention of a navigator.geolocation object, but Tapforms throws an error when I try to reference it.
Does anyone have any other ideas how I might capture my Current Location via JavaScript?
Thanks,
Pinny
Topic: Setting Current Date
Hi guys,
I’m trying to figure out how to make this work:
- I have a CheckMark field
- and would like to make value in a Date field change
- when the CheckMark field is Checked
I’ve tried different Script Approaches, with no luck so far
How would I do this?
kr.
John