Search Results for 'script'
-
Search Results
-
Hello. Basic programmer here (literally, my understanding comes from my days with BASIC).
I am trying to create a basketball season practice planner where clicking a checkbox for a practice topic automatically adds a record to a “Link To” field (joined by date field). The details for the parent topic can be stored in the child record. The practice topic from the parent form is then stored in array (foci) along with the other topics for that practice. If the checkbox is unchecked, the records in the child form are deleted for a given date and that topic is removed from the array.
This portion of the script (located in a field in the parent form) appears to work but the new child record does not appear in the linked field until records are refreshed. NB: There is a script in the child form that converts the date to text (as with var date_text below) for the search piece.
I would like to get the child record to show in the “Link to” field without needing to refresh. Any help would be greatly appreciated.
function Focus_Script() {/* variables for Practice Plan */
var practice_date = record.getFieldValue('fld-id'); //practice date in parent form
var OT = document.getFormNamed('Offensive Transition'); // child form;
var offensive_transition = record.getFieldValue('fld-id'); // watches checkbox in parent form;
var date_text = JSON.stringify(practice_date);
let foci=[];/* variables from Offensive Transition */
var OT_date_id = 'fld-id'; // date field from child record;
if (offensive_transition == true) {
/* Search Offensive Transition for existing date and add record if not there */
var records = OT.getRecordsForSearchTerm(date_text);
if (records.length !== 0) {
console.log("DATE EXISTS ALREADY"); // true condition;} else {
foci.push("Offensive Transition"); // false condition;
var new_OT_record = record.addNewRecordToField('fld-id');
new_OT_record.setFieldValue(OT_date_id,practice_date);
console.log("DATE DOES NOT EXIST");
Utils.alertWithMessage('Done.', practice_date + " added."); // false condition;}
} else {/* Delete existing record for a given date in Offensive Transition */
var OT_records = OT.getRecords();
var field_id = 'fld-id'; /date field converted to text;
for (var index = 0, count = OT_records.length; index < count; index++){
var aRecord = OT_records[index];
var field_value = aRecord.getFieldValue(field_id);
if (field_value == date_text) {
OT.deleteRecord(aRecord);
}
}
} // false condition;console.log("EOJ");
return foci;
document.saveAllChanges()Focus_Script();
Topic: Inventory Script
I have what I think is a very simple question but I sadly haven’t got a clue how to answer it.
I use Tap Forms v5 as a tool to record inventory in my cellar. Columns include:
- Brewery
- Beer
- Size
- Style
- Purchase Point
I would like to monitor the quantity of each bottle. It’s not as simple as using an integer and increasing or decreasing as fields like Purchase Point can vary depending on where the bottle was bought.
I have created a concat field that combines Brewery, Beer and Size. This field effectively creates a string for the unique beer which I think could be used.
I guess I have two options:
- A field script that for each record (circa 900) could check if the concat field equals other concat fields and count as appropriate.
- A new form which uses the concat field and does a count against each record for the concat field. To do this I would also need the script to copy the concat field, and remove any with zero quantity.
Advice is massively appreciated. Cheers