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?