Copy value to clipboard with Oracle APEX

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

Display Only Field in Oracle APEX

For other reasons I set the „Send On Page Submit“ off.

Send On Page Submit Setting

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

When decision for „Dynamic Action“

Last step is to create a „True“ Action with type „Execute JavaScript Code“ and put the following code into the Code field:

JavaScript code to copy value to clipboard
let str = apex.item("P600_VIEWNAME").getValue();

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.

Dieser Beitrag wurde unter APEX, JavaScript, Oracle, Programmierung abgelegt und mit , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert