How to create a button in Appian which copies a pre-defined text into the clipboard?

296 Views Asked by At

I found article in the Appian-community which is over two years old (see Copy Text functionality) which states that it is not possible achieve what I want:

Is it possible to configure a feature as below: A button is displayed next to a Non-editable text field. On click of the button, the text must be copied into the clipboard and the user can paste it with a simple Ctrl+V (Windows)

Peter L. (Appian Employee) over 2 years ago in reply to soujanya B

I'm not aware of any action in Appian you can take that would copy to the clipboard other than the standard CTRL + C. [...]

I am still optimistic that there might be a clever workaround since the demanded functionality is simple JS functionality. That's also the reason I am asking here and not inside the Appian Community.

function myFunction() {
  /* Get the text field */
  var copyText = document.getElementById("myInput");

  /* Select the text field */
  copyText.select();
  copyText.setSelectionRange(0, 99999); /* For mobile devices */

   /* Copy the text inside the text field */
  navigator.clipboard.writeText(copyText.value);

  /* Alert the copied text */
  alert("Copied the text: " + copyText.value);
} 
 <!-- The text field -->
<input type="text" value="Hello World" id="myInput">

<!-- The button used to copy the text -->
<button onclick="myFunction()">Copy text</button> 

Further reading:

0

There are 0 best solutions below