Thanks @Daniel_Leu. I can get it to look up your example ISBN, so it must be sensitive to real niche type books. I can see the results in the console log, but am I correct that this script should populate the fields with the results? I can’t seem to make it do that. Maybe I am looking in the wrong spot on the script to make it match the names of my fields?
Thanks
Can’t seem to get the template to work. Has the script URL changed since this was made?
Hi Brendan,
Thank you for the response and for supporting your product so well. I figured out something with a table that I can live with and am very happy with it. I am so new to this —I was trying to link-to-form in the wrong direction and, well, anyway, writing out that question forced me to articulate the problem in such a way that I figured out a solution to what I wanted and learned a little about db relationships, too. Now to dive in to the world of JavaScript….
Take care,
John
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, 4 months ago by
Daniel Leu.
-
This reply was modified 2 years, 4 months ago by
Daniel Leu.
-
This reply was modified 2 years, 4 months ago by
Daniel Leu.
-
This reply was modified 2 years, 4 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, 4 months ago by
Pinny Berlin.
-
This reply was modified 2 years, 4 months ago by
Pinny Berlin.
-
This reply was modified 2 years, 4 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, 4 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!