Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hi all,
I would like to copy my string from thingworx to my clipboard. I have found 2 ways of doing so in javascript.
1. .execCommand("copy");
2. navigator.clipboard.writeText
the issue is that thingworx does not support these 2 methods because it is a client-side operation.
How can I incorporate my custom JavaScript code in my mashup? What are the steps?
My ultimate goal is to copy text from a mashup to a clipboard.
Best Regards
If you're entitled to ThingWorx Analytics, you can download the TWX Analytics Extension. It contains multiple sub-extensions you can install individually. One extension is called "CopyToClipboard-button" and you can use this either as it is or take it as a template.
The widget copies the value of it's bound "analyticsCopyToClipboardButton" Property to the clipboard. You would bind the copyToClipboard service to an event, e.g. a button click.
If you want to copy arbitrary selections, not just widget or service return values, you would have to change one function in the runtime.js to this (by removing some lines):
var copyPropertyToClipboardFunction = function(){
document.execCommand('copy');
}