Cross Browser Update for Copy Logic on AXES Documentation

Use this Forum to register your ideas for improvements and new features to aXes. This Forum is managed by the aXes user community. LANSA cannot guarantee the accuracy of any information posted to this Forum.

Moderator: jeanmichel

Post Reply
rigor
Posts: 7
Joined: 07 Jul 2021, 12:46

Cross Browser Update for Copy Logic on AXES Documentation

Post by rigor » 15 Jun 2022, 20:14

Hi,

Good day.

I've encountered an issue with the current Javascript Copy Logic used in 2 of the Lansa Axes Documentation for USERENV and Generic Coding(https://axesdocs.lansa.com.au/index.php ... RhdGEiXQ==) and Iterating through subfiles entries(https://axesdocs.lansa.com.au/index.ph ... es-entries).

These 2 AXES Documentation both used window.clipboardData logic which works on IE but doesn't work on Chrome or Firefox. I've also confirmed this while investigating online.
Please see sample logic below:

Code: Select all

window.clipboardData.clearData();

if (sClipData != "") window.clipboardData.setData("Text",sClipData);
I've done some research and investigation and found logic that works on Lansa AXES and can also work on Cross-Browser. If it is ok with you, I would like to suggest to maybe update the current Lansa Axes Documentation for this? Thanks.
Please see logic below:
Iterating through subfiles entries - Updated Logic(https://axesdocs.lansa.com.au/index.ph ... es-entries)

Code: Select all

var sClipData = "";

var sTab = "\t";

var iSFLIndex = 1;

var oEmployee = FIELDS("Employee",iSFLIndex);

while (oEmployee !== null)

{

var oSurname = FIELDS("Surname",iSFLIndex);

var oGivenName = FIELDS("Given_Name",iSFLIndex);

sClipData += oEmployee.getValue() + sTab;

if (oSurname !== null) sClipData += oSurname.getValue() + sTab;

else sClipData += "UNKNOWN" + sTab;

if (oGivenName !== null) sClipData += oGivenName.getValue() + sTab;

else sClipData += "UNKNOWN" + sTab;

sClipData += "\n";

iSFLIndex += 1;

oEmployee = FIELDS("Employee",iSFLIndex);

}

        var textArea = document.createElement("textarea");
        textArea.value = sClipData;
        textArea.style.opacity = "0"; 
        document.body.appendChild(textArea);
        textArea.focus();
        textArea.select();

        try {
            var successful = document.execCommand('copy');
            var msg = successful ? 'successful' : 'unsuccessful';
            alert('Copying text command was ' + msg);
        } catch (err) {
            alert('Unable to copy value , error : ' + err.message);
        }

        document.body.removeChild(textArea);
USERENV and Generic Coding(https://axesdocs.lansa.com.au/index.php ... RhdGEiXQ==)

Code: Select all

sendSubfiletoClipBoard : function(oP)

{
var iSFLIndex = 0;
var iLimit = oP.sendFields.length;
var sClipData = "";
var sTab = "\t";
var sNL = "\n";
var oiterField = null;

iSFLIndex = 1;
oiterField = oP.ENV.FIELDS(oP.iterField,iSFLIndex);

while (oiterField !== null)
{
for (var i = 0; i < iLimit; i++)
{
var osendField = oP.ENV.FIELDS(oP.sendFields[i],iSFLIndex);
if (osendField !== null) sClipData += osendField.getValue() + sTab;
else sClipData += oP.notFound + sTab;
}

sClipData += sNL;
iSFLIndex += 1;
oiterField = oP.ENV.FIELDS(oP.iterField,iSFLIndex);
}

//window.clipboardData.clearData();
//if (sClipData !== "") window.clipboardData.setData("Text",sClipData);
alert(sClipData);

        var textArea = document.createElement("textarea");
        textArea.value = sClipData;
        textArea.style.opacity = "0"; 
        document.body.appendChild(textArea);
        textArea.focus();
        textArea.select();

        try {
            var successful = document.execCommand('copy');
            var msg = successful ? 'successful' : 'unsuccessful';
            alert('Copying text command was ' + msg);
        } catch (err) {
            alert('Unable to copy value , error : ' + err.message);
        }

        document.body.removeChild(textArea);

}, /* <= Note the comma */
Sample Testing
Firefox
FirefoxCopy1.PNG
FirefoxCopy1.PNG (136.42 KiB) Viewed 28419 times
FirefoxCopy2.PNG
FirefoxCopy2.PNG (142.51 KiB) Viewed 28419 times
FirefoxCopy3.PNG
FirefoxCopy3.PNG (111.54 KiB) Viewed 28419 times
Chrome
ChromeCopy1.PNG
ChromeCopy1.PNG (147.31 KiB) Viewed 28419 times
ChromeCopy2.PNG
ChromeCopy2.PNG (145.67 KiB) Viewed 28419 times
ChromeCopy3.PNG
ChromeCopy3.PNG (116.41 KiB) Viewed 28419 times
Thanks.

Kind Regards,
Rigor

Post Reply