TeamDesk Blog

Copy and paste setup forms

Have you ever encountered situation when you are working on the development branch and yet have to add some stuff into production database? In order to keep changes in production database you have to either drop the branch or carefully copy and paste object settings from production to branch, property by property.

Setup’s add/new/edit forms now feature two buttons in form’s header: Copy form data and Paste form data.

Upon clicking Copy button about 300 lines of nicely formatted JavaScript 🙂 will carefully iterate over each editable control and its state to the clipboard.

Another 300 lines of code will do the reverse – find appropriate control and restore it’s value, emulating typing, selecting, clicking and checking as necessary.

Now to the funniest part. In fact you are not restricted to production/dev. branch pair. You can try to copy everything everywhere as long as objects have common properties. And almost all of them have at least name, notes and help text.

Suppose you decided to visualize your summary view’s data via chart view. These two view types have quite a lot in common. You can simply copy summary view’s edit form and paste it into new chart view. And then the only thing’s left is to select appropriate chart type.

Or you can try to copy button’s settings into document and vice versa.

Or copy between the database and its modified copy — we’ll do our best to paste as much as possible.

One caveat to mention. At the time of writing only Chrome browser supports programmatic access to clipboard we need to perform paste. To work around this limitation, for non-conformant browsers have to display a dialog with a text box to paste clipboard data into using keyboard or menu.