Hi,
I am wanting to copy text within a container to the clipboard. I have setup a container with template text and expressions that change with different perimeters. I would use a copy to quickly copy the container contents. All the forge components I have found so far only copy text from an input field.
Thanks,
Glenn
HI @Glenn Southward , use this Js code to copy the text in Container.
regards Venkatesaiya k
Hi Venkatesaiya,
Thank you for providing that Js code. It does the job and it keeps the carriage formatting when pasted.
This piece of JavaScript should do the trick:
var node = document.getElementById($parameters.inContainerId);var copiedText = node.textContent || node.innerText;navigator.clipboard.writeText(copiedText);
(Where $parameters.inContainerId is the id of the container, which you pass to the JavaScript block as an input parameter)
Hi Jeroen,
Thanks for the reply. The Service Studio is reporting an issue with the "$". Stating unexpected "$" in the SQL statement. When I try the action in the browser it gives an "Error executing query".
Hi Glenn
The code referred by Jeroen is JavaScript so you need to use this element
Hope this helps
Hi Nuno,
Thank you for pointing that out. I was thinking that it had to be a sql thing and didn't even look for the JavaScript element. I set it up and what Jeroen provided works.
That works. Thanks to Nuno's advise I used the correct element and it works. Unfortunately, it doesn't maintain the formatting. I have several carriage returns in the screen display and the when I paste it from the clipboard all the sentences are run together.
Is there a way to keep the formatting structure?
Hi Glenn,
Not sure if you are blindly wanting to copy all the widgets alongwith the container. If yes, then have you tried a simple Copy of the container from the widget tree and paste where you want. Let me know if I have misunderstood your query.
Cheers
Hi Prabhu,
I want to be able to copy text of a specific area of my application that is showing in the browser. Something like this:
I realize I could just highlight it with the mouse and then right click and copy. I am just hoping I can come up with a way to do it with just clicking the "Copy" button.
Hi Glenn, Please refer this link, may be it helpful for you.