cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Windchill customization, copy checkin comment to clipboard

Mat
15-Moonstone
15-Moonstone

Windchill customization, copy checkin comment to clipboard

Hi there,

 

the default behavior of windchill is, that if somethings goes wrong during checkin process, the checkin comment is lost.

So I tweaked  <Windchill-installation>\codebase\templates\uwgm\cadx\checkin\checkintables.js a little to make a copy of the comment to a new window like:

 

var comment_window = window.open();
comment_window.document.writeln(comment);

(I intentionally left all code out, which "prettifies" the new window)

  works great!

 

Now I want to copy the comment directly to the clipboard.

But when I try this

// copy comment to clipboard

		navigator.clipboard.writeText(comment)
		.then(() => {
		        alert("successfully copied: " + comment);
		   })
		  .catch(() => {
			alert("something went wrong");
		   });

 I get the error under Creo 8.0.6.0, "checkintables.js Uncaught TypeError: Cannot read properties of undefined (reading 'then')"

 

What am I doing wrong?

ACCEPTED SOLUTION

Accepted Solutions
Mat
15-Moonstone
15-Moonstone
(To:Mat)

Ok, I think I found the solution

 

There is an article at w3docs.com about that.

https://www.w3docs.com/snippets/javascript/how-to-copy-the-text-to-the-clipboard-with-javascript.html

 

The third and last method works within Creo's embedded browser.

 

...
copyTextToClipboard(comment);
...
}

async function copyTextToClipboard(text) {
	try {
	  await navigator.clipboard.writeText(text);
	  console.log("Text copied to clipboard " + text);
	} catch(err) {
	  console.log('Error in copying text: ', err);
	}
  }

View solution in original post

1 REPLY 1
Mat
15-Moonstone
15-Moonstone
(To:Mat)

Ok, I think I found the solution

 

There is an article at w3docs.com about that.

https://www.w3docs.com/snippets/javascript/how-to-copy-the-text-to-the-clipboard-with-javascript.html

 

The third and last method works within Creo's embedded browser.

 

...
copyTextToClipboard(comment);
...
}

async function copyTextToClipboard(text) {
	try {
	  await navigator.clipboard.writeText(text);
	  console.log("Text copied to clipboard " + text);
	} catch(err) {
	  console.log('Error in copying text: ', err);
	}
  }

Announcements

Top Tags