Yes, there is
var copyOfRecord = record.duplicate();
document.saveAllChanges();
You can execute this from a form script.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hello All,
Does Tap Forms have a script command to duplicate the record currently being viewed. Have tried Duplicate(this) with no luck.
Many Thanks, Dan
It does make sense, thanks.
I was trying to get it to work using a script and I think I found some odd behaviour.
Say I have a linked form (stuff_link_id) and a table that I want to display a view of records in that table (stuff_table_id). If I click the checkmark button as you mention above, I get a copy of the selected stuff_link record in my table, with values magically populated.
However if I run the following (which I was hoping would populate the table with a view of whatever is linked in link) it deletes the record from link and moves it to table. Is that intentional? I expected it would do the same magic population. I’ve got a workaround which is to use duplicate() but I need to manually set all the columns.
var records=form.getRecords();
for (var rec of records){
for (var stuff_rec of rec.getFieldValue(stuff_link_id)) {
rec.addRecordToField(stuff_rec,stuff_table_id);
}
}
document.saveAllChanges();
In the table field properties, there is a dropdown called “Copy records from”.
Under this dropdown, it says “Tap Forms will copy values from the selected records based on matching field titles”.
What does this functionality actually do? From the description it looks like it can be used to populate a table with data (I want to use a table to show data from a linked form, as on iOS tables are the only way to view nested data without clicking through).
However I can’t get the feature to do anything for me.
Attachments:
You must be
logged in to view attached files.
Belay that – I got your script working!
Not sure how to explain but I had to double click the ‘line totalx’ elements to place them in the formula rather than typing out.
Attached image possibly shows this.
Anyway, I think I can work with this so much appreciated – thanking you kindly Daniel.
Attachments:
You must be
logged in to view attached files.
Thanks for the quick reply Daniel, unfortunately, the formula doesn’t seem to do anything and I get nothing in the Total calc field at all so I’m probably doing something wrong but I can’t figure out what.
I find the table incredibly difficult to deal with as I would want to turn off things like row and column titles which it doesn’t seem to allow.
Sigh, I guess I’d best attempt to deal with some javascript, er, any chance you could point me in the right direction?
Instead of separate fields, you could use a table field for your entries. There is an option to show the total at the bottom.
I don’t use the calculation field that often. But changing the formula to this might help:
IFNOTEMPTY(LINE TOTAL 1;LINE TOTAL 1;0) + IFNOTEMPTY(LINE TOTAL 2;LINE TOTAL 2;0) + IFNOTEMPTY(LINE TOTAL 3;LINE TOTAL 3;0) + ......
Another option would be to use a javascript function for the calculation.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi TF people,
I’m on the trial version of TF and attempting to set up an invoice system to replace that which I was using in filemaker.
I would like to use a Total that simply calculates the value of multiple line totals, however, if any of these are not filled in (which will usually be the case), the calculation fails.
I can make it work if I set a default of 0 but I’d rather have unused fields left blank if you see what I mean.
I can’t currently see a way of doing this and I really would rather avoid scripting if at all possible.
Is there a simple solution that I’m missing, I’m not the brightest tool in the picnic box?
TIA
Attachments:
You must be
logged in to view attached files.
…and to close the “loop” on this one Brendan; just adding a “form save all changes” to the script sorted that update thing for me.
THANKS!
Hi Richard,
Yes you can do that.
On the Script Editor screen, select a field from your Table field from the Fields list on the left. Then double-click on the Child Records Loop Snippet at the bottom-left.
Tap Forms will write the code for you that will loop through the records of the Table field and extract out the value from the selected field. Now you can write code to set those values to fields on the parent record if you like.
Thanks!
Brendan
Hello I was trying to plot a histogram of the averages generated by the table field. I can’t do this, but is there a way to read these values in a script, then in theory you could have these as a separate field and plot that?
thanks
This is likely just my JavaScript ignorance shining through, but I’m trying to use the Prompter class for the first time. My code works fine if I plop it into the global scope, but if I try to wrap it in a function, the variables never get filled in. I’ve also tried wrapping it inside a class method (passing this.xxx as the variables to fill in), but that doesn’t work, either.
Here’s my code:
// function getCopyInformation() {
var noteRowNumber;
var toRecordId;
var preserveSorter;
var prompterResultHandler = function (result) {
if (result === true) {
console.log('noteRowNumber: ' + noteRowNumber);
console.log('toRecordId: ' + toRecordId);
console.log('preserveSorter: ' + preserveSorter);
} else {
console.log('Canceled');
}
};
let prompter = Prompter.new();
prompter.cancelButtonTitle = 'Cancel';
prompter.continueButtonTitle = 'Copy';
prompter.addParameter('Note row number: ', 'noteRowNumber')
.addParameter('Target record ID: ', 'toRecordId')
.addParameter('Preserve sorter value? ', 'preserveSorter', 'popup', ['Yes', 'No'])
.show('Where do you want to copy the note?', prompterResultHandler);
// }
// var destination = getCopyInformation();
So run like this, it works. But if I uncomment the three commented lines, the three variables show as undefined (though result does still get set properly, so the log calls are still run).
Any suggestions?
No worries. Very minor issue.
It’s a Form script.
Thanks for the help, Daniel and Brendan!
The notification to reload the records is built-in to the saveAllChanges command, so there’s no way to disable it. Not without me making changes to Tap Forms at least.
I’ll think about providing an alternative save mechanism, one that doesn’t post the notification, in a future version.
Is this a Field script or a Form script?