Hi, I'm trying to copy data to the clipboard, but, I guess due to limitations, it doesn't finish copying all of it, the chain is cut off.
The idea is, in the tree grid, to make a selection and copy the values of a field determined by me. In practice, it copies the data, but without the selection it is very large and it doesn't copy anything. It copies about 200 characters at most.
Note that the variable I pass to the clipboard does have all the values, but if it is longer than about 200 characters, it does not copy anything to the clipboard.
This is my code:
if (!inArgs || !inArgs.results || !inArgs.results.getItemByIndex(0)) { return; } var thisType = this.getType(); var items = inArgs.results; var count = items.getItemCount(); var innovator = new Innovator(); var cadena =""; for(var i=0;i<items.getItemCount();i++){ var id = items.getItemByIndex(i).getProperty("id",""); var thisType = this.getType(); switch (thisType) { case "MT Ruta": var valorTomado = items.getItemByIndex(i).getProperty("mt_rut_nam",""); break; case "AIT Production Order": var valorTomado = items.getItemByIndex(i).getProperty("ait_po_code",""); break; case "MT ProdRef": var valorTomado = items.getItemByIndex(i).getProperty("mt_proref_code",""); break; case "MT LineaPVE": var valorTomado = items.getItemByIndex(i).getProperty("mt_lpve_code",""); break; case "MT Necesidad": var valorTomado = items.getItemByIndex(i).getProperty("mt_nec_code",""); break; default: // Lógica para tipos no esperados var valorTomado = items.getItemByIndex(i).getProperty("keyed_name",""); } cadena = cadena + valorTomado +"|"; } const topWindow = aras.getMostTopWindowWithAras(window); if (topWindow.work && topWindow.work.grid) { main.work.searchContainer.runSearch(); } else { parent.onRefresh(); } var buffer = cadena.substring(0,cadena.length-1); // Not all browsers support programmatic access to the clipboard (Firefox). // If clipboard access is not supported, print the result in an alert // and tell the user to copy contents with Ctrl+C. if (aras.utils.isClipboardSupported()) { copyToBuffer(buffer); return alert("Item(s) copiados."); } else { return alert("Browser does not allow clipboard access:\n\n" + buffer); } //navigator.clipboard.writeText(cadena.substring(0,cadena.length-1)); //copyToBuffer(cadena.substring(0,cadena.length-1)); return; function copyToBuffer(buffer) { alert(buffer); if (window.clipboardData) { window.clipboardData.setData('Text', buffer); } else { aras.utils.setClipboardData('Text', buffer, window); } } /* function copyToBuffer(buffer) { alert(buffer); const maxLength = 200; // Define un tamaño máximo por iteración if (window.clipboardData) { alert(1); // Para Internet Explorer window.clipboardData.setData('Text', buffer); } else { alert(2); let start = 1; alert(buffer.length); while (start < buffer.length) { const part = buffer.substring(start, start + maxLength); aras.utils.setClipboardData('Text', part, window); start += maxLength; alert(start); // } alert("Texto copiado al portapapeles en partes."); } } */
I have tried several ways, but without any luck.
As a base, I have taken the code from:
https://github.com/ArasLabs/copy-to-clipboard
Any idea??. Too many thanks!!!