During a presentation of my actual business project I realised that one of my end user selected the text from a „Display Only“ page item to copy the value into the clipboard. As I have 6 different page items on the page, I thought there must be an easier way with less clicks.
I created a „Display Only“ page item with name „P600_VIEWNAME“.
For other reasons I set the „Send On Page Submit“ off.
Just for the Layout you can add the icon „fa-copy“ in the „Appearance“ setting of this page item to show a copy symbol next the the page item.
Now I created a „Dynamic Action“ with the following „When“ condition:
Event: Click
Selection Type: jQuery Selector
jQuery Selector: P600_VIEWNAME
If you decide to enable „Send On Page Submit“ the jQuery Selector is called „P600_VIEWNAME_DISPLAY“.
Last step is to create a „True“ Action with type „Execute JavaScript Code“ and put the following code into the Code field:
let str = apex.item("P600_VIEWNAME").getValue();
navigator.clipboard.writeText(str);
apex.message.showPageSuccess('Copied ' + str + ' to Clipboard!');
The first line takes the value from the Page Item and save it in a variable. Next line put the value from the variable into the clipboard. And the last line shows a success message with the copied value on the APEX page. To use it with different page items you have to repeat the step with the „Dynamic Action“ for each item.