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)
71 replies
-
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.
-
Copy to Clipboard is not yet available :-(
Birger
-
Sad to see it's not available yet. I would use this.
-
Me too!
-
Must be add!!!
-
++ :-) as well! KE
-
need this, too!
-
:( need this, too
-
I would also find this very useful. Thanks for all your work! =)
-
need this too.
-
This would be very useful to send data to Shortcuts workflows. 1+ !!!
-
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?
-
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>")
-
Thanks Sean, that works!
Is there any way to make it focus on the contents of just one field in the record?
-
Not that I'm aware of. It is a long awaited feature request.
-
I see that. :) Looking forward to the development.
-
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.
-
thanks Sean for sharing - this was really helpful!
-
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.
-
Sorry, I misunderstood your question. I thought you wanted set the focus of a Ninox field. D'oh!
-
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.
-
For the record, Sean and Bastian did the heavy lifting. I'm just really good at copy paste. :)
-
a specific character contained in the field to copy prevents this script from working: '
Content aside
- Status Answered
-
1
Likes
- 8 mths agoLast active
- 71Replies
- 7573Views
-
10
Following