144
Views
10
Comments
Solved
Copy container text to clipboard
Question
Application Type
Reactive

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

2024-01-04 09-21-21
Venkatesaiya
Solution

HI @Glenn Southward , use this Js code to copy the text in Container.
 


regards 
Venkatesaiya k

UserImage.jpg
Glenn Southward

Hi Venkatesaiya,

Thank you for providing that Js code. It does the job and it keeps the carriage formatting when pasted.

Thanks,

Glenn




2022-07-11 14-05-36
Jeroen Barnhoorn

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)

UserImage.jpg
Glenn Southward

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".



2016-04-21 18-13-58
Nuno Rolo
 
MVP

Hi Glenn

The code referred by Jeroen is JavaScript so you need to use this element 

Hope this helps

UserImage.jpg
Glenn Southward

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.

Thanks,

UserImage.jpg
Glenn Southward

Hi Jeroen,

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?

Thanks,

Glenn

2023-12-08 17-21-38
Prabhu Sanguthiagarajan

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

UserImage.jpg
Glenn Southward

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.

Thanks,

2024-01-04 09-21-21
Venkatesaiya

Hi Glenn, 
Please refer this link, may be it helpful for you.

2024-01-04 09-21-21
Venkatesaiya
Solution

HI @Glenn Southward , use this Js code to copy the text in Container.
 


regards 
Venkatesaiya k

UserImage.jpg
Glenn Southward

Hi Venkatesaiya,

Thank you for providing that Js code. It does the job and it keeps the carriage formatting when pasted.

Thanks,

Glenn




Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.