How can I copy the contents of a column of type "Multiple lines of text" - Enhanced rich text (Rich text with pictures, tables, and hyperlinks) - to the clipboard?
The contents of a column of the type "multiple text lines" - plain text - I get about the following code in the clipboard:
var Betreff = fd.field('Betreff').value;
//alert("Betreff: "+Betreff);
function copy2Clipboard(str) {
ta = document.createElement('textarea');
ta.value = str;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
document.body.removeChild(ta);
};
copy2Clipboard(Betreff)
We've found one option of copying the content from Enhanced rich text to the clipboard as HTML.
Please follow the below steps to set up:
Add a Text Field in the form. Note: the field should be visible on the form.
Add Custom Button in the form.
Add the following script in OnClick Settings. Replace field names in the code with the internal names of the fields in the Form.
fd.field('TextField').value = fd.field('MultilineTextField').value;
setTimeout(function(){
var copyText = $(fd.field('TextField').$el).find('input')[0];
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
}, 500);
Any input on how I might modify this example to copy the contents of the SharePoint 'Title' field to the clipboard? I was not able to alter this to meet this different need. Thanks!
You can add a custom button to the form and use this code to copy the content from the Title field:
var copyText = $(fd.field('Title').$el).find('input')[0];
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /*For mobile devices*/
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
alert("Copied the text: " + copyText.value);
This works great!
Now if you don't mind I'll see if we can add another wrinkle. In this case we are looking at the Edit form but the title field has been disabled. The line copyText.select(); doesn't work since it can't select the disabled text.
The alert on the copyText.value does work. Any thoughts?