Copying record data between documents

TapForms 5 doesn’t provide a way to copy data from one document to another one. But since a few releases, there is support to copy data to and from the clipboard. This can be used for data exchange between two documents.

Following functions copies the currentRecord in JSON format to the clipboard:

function copyRecordToClipboard(currentRecord){
   let currentForm = currentRecord.form;
   let rec = {};
   let fields = currentForm.getFields();
   for (f of fields){
      rec[] = currentRecord.getFieldValue(f.getId());
   rec['recUrl'] = currentRecord.getUrl(); // add record url so we can backlink to original record
   console.log("Copied record: " + JSON.stringify(rec));

Then in the target document, I create a new record based on the just copied data:

function copyRecordFromClipboard(currentForm){
   let newRecord = currentForm.addNewRecord();
   let fields = currentForm.getFields();
   let rec = JSON.parse(Utils.copyTextFromClipboard());
   for (f of fields){
      newRecord.setFieldValue(f.getId(), rec[]);
   console.log("Created new record from : " + JSON.stringify(rec));
   return newRecord;

There is one additional trick that comes in very handy: Instead of switching from the first document to the second document using the GUI, I use


in my script to automate this step. The value for tfUrl is created using ‘File > Copy Record Link’ in the target document.

The given example code to exchange record data between two documents works well, when all field names of the two documents are identical. Otherwise, the same principle still can be used, but at least one ‘for … loop’ needs to be changed into separate field assignments.

Did you like this post? Did you use the given code? Please consider supporting me by buying me a coffee!

Buy Me A Coffee


Leave a Reply

Your email address will not be published. Required fields are marked *

Web Design Consulting

Do you need help designing your web site or getting Backlight working the way you want? Contact me to discuss your idea or project.

Buy me a Coffee

If you like what I share here, please consider buying me a coffee or a print. This helps keeping me motivated to continue posting. Thank you!

Buy Me A Coffee