0

Copy to Clibboard button

Can I create a button to select the contents of a field and copy them to Clipboard? (In FM Pro that was v straightforward)

43replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Sean
    • Sean
    • 1 yr ago
    • Accepted
    • Reported - view

    Max, I don't know which version you are using, but this one worked for me...

     

    html("<button onclick='copyToClipboard(""" + 'Formula Field' + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    Hans, Not that I'm aware of, but you can use "style" to modify the appearance of the button. Search on style for the HTML button tag.

    Like
    • Birger H
    • Birger_H
    • 4 yrs ago
    • Reported - view

    Copy to Clipboard is not yet available :-(

    Birger

    Like
    • Art
    • Personal
    • Art
    • 3 yrs ago
    • Reported - view

    Sad to see it's not available yet. I would use this.

    Like
  • Me too!

    Like
  • Must be add!!!

    Like
  • ++ :-)  as well! KE

    Like
    • Timo L.
    • blickfang Internet- & Werbeagentur GmbH
    • Timo_L
    • 2 yrs ago
    • Reported - view

    need this, too!

    Like
    • majlo
    • majlo
    • 2 yrs ago
    • Reported - view

    :( need this, too

    Like
  • I would also find this very useful. Thanks for all your work! =)

    Like
    • Eric Plet
    • Retraité
    • Eric_Plet
    • 2 yrs ago
    • Reported - view

    need this too.

    Like
  • This would be very useful to send data to Shortcuts workflows. 1+ !!!

    Like
    • Halio
    • Halio
    • Halio
    • 2 yrs ago
    • Reported - view

    Any update on this?

    Just to clarify, there is no way to program a button to copy the content from a field to the clipboard?

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    Hello, I found this solution online and adapted it to work in Ninox. The code goes in Formula field and it copies the current record information to the clipboard...

     

    html("<button onclick='copyToClipboard(""" + concat(this) + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

    Like
    • Hans
    • Hans
    • 2 yrs ago
    • Reported - view

    Thanks Sean, that works! 

    Is there any way to make it focus on the contents of just one field in the record?

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    Not that I'm aware of. It is a long awaited feature request.

    Like
    • Hans
    • Hans
    • 2 yrs ago
    • Reported - view

    I see that. :) Looking forward to the development. 

    Like
    • Bastian Rohde
    • Bastian Rohde Immobilien
    • Bastian_Rohde
    • 2 yrs ago
    • Reported - view

    sure that works - you just need to replace this piece here in the first line:

     concat(this) 

    I have replaced this with one column and it works.

    Like
    • Bastian Rohde
    • Bastian Rohde Immobilien
    • Bastian_Rohde
    • 2 yrs ago
    • Reported - view

    thanks Sean for sharing - this was really helpful!

    Like
    • Hans
    • Hans
    • 2 yrs ago
    • Reported - view

    Bingo! That is the perfect solution.

    Just in case anyone is unclear about how to make this work...

    Use the "Fx Formula" option to add a formula field to your record. (I.e. not a button field - tried that, didn't work)

    Add the following code where the Formula code goes:

    html("<button onclick='copyToClipboard(""" + concat('Project Name') + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    Where I have:

    'Project Name'

    in concat('Project Name')

    is where you will want to put the name of the field you want to copy. If you want to copy the whole record, simply add the word

    this

    as in contcat(this)

    ...and you are done, and Ninox has one less development item on their list.

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    Sorry, I misunderstood your question. I thought you wanted set the focus of a Ninox field. D'oh! 😬

    Like
    • hugh.bs
    • hughbs
    • 2 yrs ago
    • Reported - view

    Thank you Sean and Hans, the perfect solution! And one can change the name on the button to the name of the field being copied.

    Like
    • Hans
    • Hans
    • 2 yrs ago
    • Reported - view

    For the record, Sean and Bastian did the heavy lifting. I'm just really good at copy paste. :)

    Like
    • Eric Plet
    • Retraité
    • Eric_Plet
    • 2 yrs ago
    • Reported - view

    a specific character contained in the field to copy prevents this script from working: '

    Like
    • Eric Plet
    • Retraité
    • Eric_Plet
    • 2 yrs ago
    • Reported - view

    sample text:

    youtube-dl -f 251 --no-cache-dir -o '/Library/WebServer/Documents/Médiathèque/ Commodores/The Commodores Anthology/Easy (Extended Version)/Easy (Extended Version) - Album Studio - Opus 160k.%(ext)s' https://youtu.be/-_z35XZWiP4

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    The only sort-of-solution I found was this...

     

    html("<button onclick='copyToClipboard(""" + replace(FieldToCopy, "'", "") + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    If you insert the string directly it works, but it's not what you're looking for. I'm not sure how to get around it.

     

    html("<button onclick='copyToClipboard(""youtube-dl -f 251 --no-cache-dir -o '/Library/WebServer/Documents/Médiathèque/ Commodores/The Commodores Anthology/Easy (Extended Version)/Easy (Extended Version) - Album Studio - Opus 160k.%(ext)s' https://youtu.be/-_z35XZWiP4"")'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

    Like
Like Follow
  • Status Answered
  • 7 mths agoLast active
  • 43Replies
  • 6361Views
  • 5 Following