Hi John,
It’s not directly possible to populate all of those fields in child forms just by selecting a value from a Pick List.
But it could be done with a Field Script. The Field Script could monitor the value entered into field with the Pick List. Then you could add records to the child form and set the field values appropriately.
However, that’s a rather complex bit of coding to do.
How’s your JavaScript?
Thanks,
Brendan
I’m a little confused about the behavior of pick list values. If I create a list (say Easy, Medium, Hard) and assign it to fields/records in various forms, if I later want to rename “Hard” to “Difficult” (or delete it altogether), that change doesn’t propagate to the records currently assigned to that value. It then becomes difficult to trust whether a record’s assigned values actually reflect the list values in the preferences.
There is a dialog warning, so I guess this behavior is a feature? Perhaps there’s a script that can propagate these value changes? Even with a script, you would still have to track down which fields reference the pick list you are modifying. Currently, I have to go through and manually reassign values for every record in every form that references the modified list value, which is a huge pain.
Hi,
I have a table with a list of publishers and another with countries of origin
I would like for each publisher, the country field to be filled in automatically
Or maybe have created a table with two fields
In the scripts dialog, there may be one offered but I don’t know which one and how to use it
Best
Another option is using a script. Following form script updates all checkmark fields of the current record. To clear all checkmarks, use Update_All_Checkmarks(false);. To set all checkmarks, use Update_All_Checkmarks(true);
function Update_All_Checkmarks(value) {
let fields = form.getFieldsForType('check_mark');
for (field of fields){
console.log("Clearing check mark: " + field.name);
record.setFieldValue(field.getId(), value);
}
document.saveAllChanges();
}
// clear checkmarks
Update_All_Checkmarks(false);
// set checkmarks
//Update_All_Checkmarks(true);
-
This reply was modified 2 years, 10 months ago by
Daniel Leu.
-
This reply was modified 2 years, 10 months ago by
Daniel Leu.
-
This reply was modified 2 years, 10 months ago by
Daniel Leu.
-
This reply was modified 2 years, 10 months ago by
Daniel Leu.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Daniel, Brendon,
This was actually just what I needed for my own database. Here’s the code I used to get it to work:
document.getFormNamed(‘Scripts’).runScriptNamed(‘prompterHelper’);
async function Selected_Items_Change_Follow_Up_Date() {
//Change Follow Up Date for Selected Items
let selected_id = ‘fld-ef53cc6a7a5f4ed2a51f7de0fa046400’;
let follow_up_date_id = ‘fld-6fa53ab54482495289f38b069d3c713f’;
try {
await textPrompter(‘Enter Follow Up Date (YYYY-MM-DD):’);
console.log(“User entered: ” + prompterVar);
} catch (errorText) {
console.log(‘User clicked cancel’);
return;
}
//let new_date = new Date(‘2023-07-03T00:00:00’);
let new_date = new Date(Date.parse(prompterVar + ‘T00:00:00’));
for(let baserecord of search.getRecords()) {
if (baserecord.getFieldValue(selected_id) === true) {
baserecord.setFieldValue(follow_up_date_id, new_date);
baserecord.setFieldValue(selected_id, false);
}
}
document.saveAllChanges();
}
Selected_Items_Change_Follow_Up_Date();
-
This reply was modified 2 years, 10 months ago by
Pinny Berlin.
-
This reply was modified 2 years, 10 months ago by
Pinny Berlin.
-
This reply was modified 2 years, 9 months ago by
Brendan.
I wondering the best way to prevent duplication of record names.
Rough Over view
I have these forms
Products
Formulations (many formulations records can link to many Products records)
Ingredients (many ingredients can link to many Formulations)
Each record has a name, How do I prevent duplication? Can you have the name field as you name it check no other record on the form contains the same record name?
IS this built in or does this need to be scripted?
any help would be appreciated.
-
This topic was modified 2 years, 10 months ago by
Greg Spink.
I’m sorry for that. Yes, it’s always important to make backups frequently. Sorry this happened to you.
I didn’t have your document and the script was just off the top of my head and wasn’t tested with your data.
That is cool.
How about a script to do that? Would be really appreciated.
The field script would be triggered by a change in the stepper field.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
But, if I was able to build a script (which I can’t), could it be activated by the stepper or do I have to go into settings and select the script and run that? That would be more work that activating 2 steppers I would think?
You would need to use a Script Field to manage this. The Script Field would monitor the value of your stepper field and add to the value of the second field.
Brilliant!. Thank you it works…But the form doesn’t update. I have to close the database/document and reopen to see the results. I am executing the operation with form level script and I am using the “document.saveAllChange();” command but it doesn’t show results until I close and reopen.
Thoughts?
Thanks again!
The result is stored in the variable d. So you can take this and store the values in their respective fields.
record.setFieldValue(symbol_field_id, d["Global Quote"]["01. symbol"]);
...
document.saveAllChanges();
Most likely you want to create a new record where you save all these information so you can do some analysis over time.
The JavaScript API documentation is here: https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Alan,
The Duplicate Document function just takes a copy of the document as is, copies it, and assigns it a new, unique Document ID. That’s all it does. So all field IDs, record IDs, form IDs, and so on will all be identical.
But a script should not make changes to a different document. It should still only operate on its own forms.
Can you check the Document IDs on each document to see if they are in fact different?
Thanks,
Brendan
Don’t know if I should have rewrote my original post. But looking at this further, I think “Duplicate Document” is referencing the same actual script object? When I make a change to the script in the duplicate document, those edits appear in the script in the original document.