Copy to clipboard
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:
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:b137186c-5ab2-46a2-aa65-3ee09070890b:type=javascript&text=if%20%28%21inArgs%20%7C%7C%20%21inArgs.results%20%7C%7C%20%21inArgs.results.getItemByIndex%280%29%29%0A%7B%0A%20%20%20%20return%3B%0A%7D%0A%0Avar%20thisType%20%3D%20this.getType%28%29%3B%0A%09%0Avar%20items%20%3D%20inArgs.results%3B%0Avar%20count%20%3D%20items.getItemCount%28%29%3B%0Avar%20innovator%20%3D%20new%20Innovator%28%29%3B%0Avar%20cadena%20%3D%22%22%3B%0A%0Afor%28var%20i%3D0%3Bi%3Citems.getItemCount%28%29%3Bi%2B%2B%29%7B%0A%20%20%20%20var%20id%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22id%22%2C%22%22%29%3B%0A%20%20%20%20%0A%20%20%20%20var%20thisType%20%3D%20this.getType%28%29%3B%0A%0A%20%20%20%20switch%20%28thisType%29%20%7B%0A%20%20%20%20%20%20%20%20case%20%22MT%20Ruta%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22mt_rut_nam%22%2C%22%22%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20case%20%22AIT%20Production%20Order%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22ait_po_code%22%2C%22%22%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20case%20%22MT%20ProdRef%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22mt_proref_code%22%2C%22%22%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20case%20%22MT%20LineaPVE%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22mt_lpve_code%22%2C%22%22%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%0A%20%20%20%20%20%20%20%20case%20%22MT%20Necesidad%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22mt_nec_code%22%2C%22%22%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20default%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20L%C3%B3gica%20para%20tipos%20no%20esperados%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20valorTomado%20%3D%20items.getItemByIndex%28i%29.getProperty%28%22keyed_name%22%2C%22%22%29%3B%0A%20%20%20%20%7D%0A%0A%0A%20%20%20%20cadena%20%3D%20cadena%20%2B%20valorTomado%20%2B%22%7C%22%3B%0A%20%20%20%20%0A%7D%0A%20%20%20%20const%20topWindow%20%3D%20aras.getMostTopWindowWithAras%28window%29%3B%20%0A%20%20%20%20if%20%28topWindow.work%20%26%26%20topWindow.work.grid%29%20%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20main.work.searchContainer.runSearch%28%29%3B%0A%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20parent.onRefresh%28%29%3B%0A%20%20%20%20%7D%0A%0Avar%20buffer%20%3D%20cadena.substring%280%2Ccadena.length-1%29%3B%0A%0A%2F%2F%20Not%20all%20browsers%20support%20programmatic%20access%20to%20the%20clipboard%20%28Firefox%29.%0A%2F%2F%20If%20clipboard%20access%20is%20not%20supported%2C%20print%20the%20result%20in%20an%20alert%20%0A%2F%2F%20and%20tell%20the%20user%20to%20copy%20contents%20with%20Ctrl%2BC.%0Aif%20%28aras.utils.isClipboardSupported%28%29%29%0A%7B%0A%20%20%20%20copyToBuffer%28buffer%29%3B%0A%20%20%20%20return%20alert%28%22Item%28s%29%20copiados.%22%29%3B%0A%7D%20%0Aelse%20%0A%7B%0A%20%20%20%20return%20alert%28%22Browser%20does%20not%20allow%20clipboard%20access%3A%5Cn%5Cn%22%20%2B%20buffer%29%3B%0A%7D%0A%0A%2F%2Fnavigator.clipboard.writeText%28cadena.substring%280%2Ccadena.length-1%29%29%3B%0A%2F%2FcopyToBuffer%28cadena.substring%280%2Ccadena.length-1%29%29%3B%0Areturn%3B%0A%0A%0Afunction%20copyToBuffer%28buffer%29%20%7B%0A%20%20%20%20alert%28buffer%29%3B%0A%20%20%20%20if%20%28window.clipboardData%29%20%7B%0A%20%20%20%20%20%20%20%20window.clipboardData.setData%28%27Text%27%2C%20buffer%29%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20aras.utils.setClipboardData%28%27Text%27%2C%20buffer%2C%20window%29%3B%0A%20%20%20%20%7D%0A%7D%20%20%20%20%0A%0A%0A%2F%2A%0Afunction%20copyToBuffer%28buffer%29%20%7B%0A%20%20%20%20alert%28buffer%29%3B%0A%20%20%20%20const%20maxLength%20%3D%20200%3B%20%2F%2F%20Define%20un%20tama%C3%B1o%20m%C3%A1ximo%20por%20iteraci%C3%B3n%0A%20%20%20%20if%20%28window.clipboardData%29%20%7B%0A%20%20%20%20%20%20%20%20alert%281%29%3B%0A%20%20%20%20%20%20%20%20%2F%2F%20Para%20Internet%20Explorer%0A%20%20%20%20%20%20%20%20window.clipboardData.setData%28%27Text%27%2C%20buffer%29%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20alert%282%29%3B%0A%20%20%20%20%20%20%20%20let%20start%20%3D%201%3B%0A%20%20%20%20%20%20%20%20alert%28buffer.length%29%3B%0A%20%20%20%20%20%20%20%20while%20%28start%20%3C%20buffer.length%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20const%20part%20%3D%20buffer.substring%28start%2C%20start%20%2B%20maxLength%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20aras.utils.setClipboardData%28%27Text%27%2C%20part%2C%20window%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20start%20%2B%3D%20maxLength%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20alert%28start%29%3B%0A%2F%2F%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20alert%28%22Texto%20copiado%20al%20portapapeles%20en%20partes.%22%29%3B%0A%20%20%20%20%7D%0A%7D%0A%2A%2F%0A]
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!!!